-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.py
36 lines (27 loc) · 963 Bytes
/
index.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import datetime
import random
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from django.utils import simplejson as json
from mako.template import Template
from counter import Counter
class Index(webapp.RequestHandler):
def get(self):
template = Template(filename="index.html",
input_encoding='utf8',
output_encoding='utf8')
distance = Counter.get_by_key_name('distance')
if not distance:
km = 0
else:
km = distance.value/1000
output = template.render(kilometers=km)
self.response.out.write(output)
application = webapp.WSGIApplication(
[('/', Index)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()