-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
30 lines (19 loc) · 742 Bytes
/
Copy pathmain.py
File metadata and controls
30 lines (19 loc) · 742 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
"""Main File for the basic handlers."""
import jinja2
import os
import webapp2
# import database
TEMPLATE_DIR = os.path.join(os.path.dirname(__file__), 'templates')
JINJA_ENV = jinja2.Environment(loader=jinja2.FileSystemLoader(TEMPLATE_DIR),
autoescape=True)
class BaseHandler(webapp2.RequestHandler):
def render_str(self, template, params):
t = JINJA_ENV.get_template(template)
return t.render(params)
def render(self, template, kw):
self.response.out.write(self.render_str(template, kw))
class IndexHandler(BaseHandler):
def get(self):
self.render('index.html', {})
app = webapp2.WSGIApplication([('/', IndexHandler),
], debug=True)