-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandlers.py
30 lines (23 loc) · 833 Bytes
/
handlers.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
# -*- coding: utf-8 -*-
import datetime
import webapp2
from webapp2_extras import jinja2
class BaseHandler(webapp2.RequestHandler):
"""
BaseHandler for all requests all other handlers will
extend this handler
"""
@webapp2.cached_property
def jinja2(self):
return jinja2.get_jinja2(app=self.app)
def render_template(self, template_name, template_values):
self.response.write(self.jinja2.render_template(
template_name, **template_values))
def render_string(self, template_string, template_values):
self.response.write(self.jinja2.environment.from_string(
template_string).render(**template_values))
class PageHandler(BaseHandler):
def root(self):
context = {
}
return self.render_template('base.html', context)