-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
25 lines (19 loc) · 871 Bytes
/
main.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
import os.path
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template
class BasePage(webapp.RequestHandler):
def get_host(self):
return "http://" + os.environ['SERVER_NAME'] + ((':' + os.environ['SERVER_PORT']) if os.environ['SERVER_PORT'] != '80' else '')
def render(self, template_file, template_vars={}):
template_vars['host'] = self.get_host()
return self.response.out.write(template.render(os.path.join(os.path.dirname(__file__), 'views/'+ template_file), template_vars))
class MainHandler(BasePage):
def get(self):
self.render("index.html", {})
def main():
application = webapp.WSGIApplication([('/', MainHandler)],
debug=True)
util.run_wsgi_app(application)
if __name__ == '__main__':
main()