-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
92 lines (68 loc) · 2.91 KB
/
main.py
File metadata and controls
92 lines (68 loc) · 2.91 KB
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
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python
import json
from google.appengine.ext import ndb
from gameon import gameon
from ws import ws
import os
import webapp2
import jinja2
import fixtures
from gameon.gameon_utils import GameOnUtils
JINJA_ENVIRONMENT = jinja2.Environment(
loader=jinja2.FileSystemLoader(os.path.dirname(__file__)),
extensions=['jinja2.ext.autoescape'])
config = {'webapp2_extras.sessions': dict(secret_key='93986c9cdd240540f70efaea56a9e3f2')}
class BaseHandler(webapp2.RequestHandler):
def render(self, view_name, extraParams={}):
template_values = {
'fixtures': fixtures,
'ws': ws,
'json': json,
'GameOnUtils': GameOnUtils,
# 'facebook_app_id': FACEBOOK_APP_ID,
# 'glogin_url': users.create_login_url(self.request.uri),
# 'glogout_url': users.create_logout_url(self.request.uri),
# 'url':self.request.uri,
# 'num_levels': len(LEVELS)
}
template_values.update(extraParams)
template = JINJA_ENVIRONMENT.get_template(view_name)
self.response.write(template.render(template_values))
class MainHandler(BaseHandler):
def get(self):
noads = self.request.get('noads', True)
self.render('templates/index.jinja2', {'noads': noads})
class TestHandler(BaseHandler):
def get(self):
self.render('templates/tests.jinja2')
class PrivacyHandler(BaseHandler):
def get(self):
self.render('templates/privacy.jinja2')
class ContactHandler(BaseHandler):
def get(self):
self.render('templates/contact.jinja2')
class TermsHandler(BaseHandler):
def get(self):
self.render('templates/terms.jinja2')
class PingHandler(webapp2.RequestHandler):
"""Simple health check endpoint."""
def get(self):
self.response.headers['Content-Type'] = 'application/json'
self.response.write(json.dumps({'status': 'ok'}))
class SitemapHandler(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/xml'
template_values = {
}
template = JINJA_ENVIRONMENT.get_template('templates/sitemap.xml')
self.response.write(template.render(template_values))
app = ndb.toplevel(webapp2.WSGIApplication([
('/', MainHandler),
('/tests', TestHandler),
('/privacy', PrivacyHandler),
('/terms', TermsHandler),
# ('/about', AboutHandler),
('/contact', ContactHandler),
('/sitemap', SitemapHandler),
('/ping', PingHandler),
] + gameon.routes, debug=ws.debug, config=config))