source: src/django_gheat/website/osm_proxy.py@ 9377

Last change on this file since 9377 was 9192, checked in by rick, 14 years ago

Forgot to include actual osm_proxy caching code.

File size: 601 bytes
Line 
1#
2# Hack to cache OSM tile images locally, using file based django caching
3#
4# Rick van der Zwet <info@rickvanderzwet.nl>
5#
6from django.views.decorators.cache import cache_page
7from django.http import HttpResponse
8
9import settings
10import random
11import urllib
12
13# Create your views here.
14@cache_page(cache=settings.OSM_CACHE)
15def osm_proxy(request,zoom,x,y):
16 mirror = random.choice(['a','b','c'])
17 url = 'http://%s.tile.openstreetmap.org/%s/%s/%s.png' % (mirror, zoom, x, y)
18 data = urllib.urlopen(url).read()
19 response = HttpResponse(mimetype="image/png")
20 response.write(data)
21 return response
Note: See TracBrowser for help on using the repository browser.