-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
35 lines (28 loc) · 932 Bytes
/
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
import cgi
import wsgiref.handlers
import settings
from feed import *
from google.appengine.ext import webapp
class Index(webapp.RequestHandler):
def get(self):
context = {
'site_url': settings.SITE_URL,
'debug': settings.DEBUG,
}
# calculate the template path
path = os.path.join(os.path.dirname(__file__), 'templates', 'index.html')
# render the template with the provided context
output = template.render(path, context)
self.response.out.write(output)
class Entries(webapp.RequestHandler):
def get(self, enum):
return self.response.out.write(u"entry" + enum)
def main():
application = webapp.WSGIApplication(
[('/', Index),
('/feed/(1|5)(.*)$', Feed), # the 1min feed need a secret token
('/gen/(1|5)$', FeedGenerate),
('/entry/(\d+)$', Entries)], debug = True)
wsgiref.handlers.CGIHandler().run(application)
if __name__ == "__main__":
main()