-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhkvgae.py
82 lines (58 loc) · 2.42 KB
/
hkvgae.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
import urllib2
import json
import jinja2
import os
jinjaEnvironment = jinja2.Environment(
loader = jinja2.FileSystemLoader(os.path.dirname(__file__)))
class MainPage(webapp.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/html'
# url = 'https://www.googleapis.com/books/v1/users/115635621284467092412/bookshelves/4/volumes?key=AIzaSyB88fqZ8mHe6R3HPg7V8IcHPQ3TcjNWp-U'
#
# #Try to make a rest call
# totalItems = -1
# u = urllib2.urlopen(url)
# if u.code == 200:
# d = json.load(u)
# totalItems = d['totalItems']
#
# templateValues = {'totalItems' : totalItems,
# 'pageid' : 'about'
# }
template = jinjaEnvironment.get_template('index.html')
self.response.out.write(template.render({}))
class BlogPage(webapp.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/html'
templateValues = {
'pageid' : 'blog'
}
template = jinjaEnvironment.get_template('blog.html')
self.response.out.write(template.render(templateValues))
class PulsePage(webapp.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/html'
templateValues = {
'pageid' : 'pulse'
}
template = jinjaEnvironment.get_template('pulse.html')
self.response.out.write(template.render(templateValues))
class CVPage(webapp.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/html'
templateValues = {
'pageid' : 'cv'
}
template = jinjaEnvironment.get_template('cv.html')
self.response.out.write(template.render(templateValues))
application = webapp.WSGIApplication([('/', MainPage),
('/pulse', PulsePage),
('/blog', BlogPage),
('/cv', CVPage),
], debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()