source: subversion/sites/other/tilesAtHome_tahngo/tah_intern/views.py @ 9049

Revision 9049, 1.2 KB checked in by spaetz, 6 years ago (diff)

don't cache the Log file view

Line 
1from django.http import HttpResponse
2from tah.tah_intern.models import Blank, Layer
3from django.core.exceptions import ObjectDoesNotExist
4from django.views.decorators.cache import cache_control
5
6@cache_control(no_cache=True)
7def show_log(request):
8  read_size=1024
9  #TODO use a setting for the log file location?
10  f = open('/var/www/tah/tah_intern/tah.log', 'rU')
11  offset = read_size
12  f.seek(0, 2)
13  file_size = f.tell()
14  if file_size < offset:
15    offset = file_size
16  f.seek(-1*offset, 2)
17  read_str = f.read(offset)
18  # Remove newline at the end
19  if read_str[offset - 1] == '\n':
20    read_str = read_str[:-1]
21  lines = read_str.split('\n')
22  f.close()
23  return HttpResponse("\n".join(lines[-10:]), mimetype="text/plain")
24
25def index(request):
26  return HttpResponse('')
27
28def show(request,layer,x,y,z):
29  retcode = 0
30  file=("/var/www/osm/Tiles/Gfx/unknown.png","/var/www/osm/Tiles/Gfx/sea.png","/var/www/osm/Tiles/Gfx/sea.png","/var/www/osm/Tiles/Gfx/error.png")
31  try:
32    l = Layer.objects.get(name=layer)
33  except ObjectDoesNotExist:
34    retcode = 3
35
36  if retcode == 0:
37    retcode = int(Blank(layer=l,z=z,x=x,y=y))
38
39  image_data = open(file[retcode], "rb").read()
40  return HttpResponse(image_data, mimetype="image/png")
Note: See TracBrowser for help on using the repository browser.