-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
executable file
·49 lines (38 loc) · 1.4 KB
/
main.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
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
import wsgiref.handlers
from google.appengine.ext import webapp
from google.appengine.api import memcache
import models
import helpers
import logging
class MainHandler(webapp.RequestHandler):
@helpers.write_response
@helpers.cached('main')
def get(self):
return helpers.render_template(self, 'webviews/front.html', {})
class GeoRSSHandler(webapp.RequestHandler):
@helpers.write_response
@helpers.cached('georss', timeout=300)
def get(self):
return helpers.render_template(self, 'webviews/georss.html', {'items': models.get_tweets()})
class GeoJSONHandler(webapp.RequestHandler):
@helpers.write_response
@helpers.cached('geojson', timeout=300)
def get(self):
return helpers.render_template(self, 'webviews/geojson.html', {'items': models.get_tweets(100)})
class GeoKMLHandler(webapp.RequestHandler):
@helpers.write_response
@helpers.set_content_type("text/plain")
@helpers.cached('geokml', timeout=300)
def get(self):
return helpers.render_template(self, 'webviews/geokml.html', {'items': models.get_tweets(100)})
def main():
application = webapp.WSGIApplication([
('/', MainHandler),
('/georss', GeoRSSHandler),
('/geojson', GeoJSONHandler),
('/kml', GeoKMLHandler),
], debug=True)
wsgiref.handlers.CGIHandler().run(application)
if __name__ == '__main__':
main()