-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
31 lines (25 loc) · 857 Bytes
/
app.py
File metadata and controls
31 lines (25 loc) · 857 Bytes
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
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app
import logging
import os
import random
import webapp2
if 'SERVER_SOFTWARE' in os.environ:
PROD = not os.environ['SERVER_SOFTWARE'].startswith('Development')
else:
PROD = True
class BaseHandler(webapp2.RequestHandler):
def render_template(self, f, template_args):
path = os.path.join(os.path.dirname(__file__), "templates", f)
self.response.out.write(template.render(path, template_args))
class IndexPage(BaseHandler):
def get(self):
self.render_template('index-template.html', {'prod': PROD, 'r': random.random()})
application = webapp2.WSGIApplication(
[('/', IndexPage), ('/.*',IndexPage)],
debug=True
)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()