-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
46 lines (32 loc) · 1.01 KB
/
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
"""
main.py
Primary App Engine app handler
"""
import sys, os
package_dir = "packages"
package_dir_path = os.path.join(os.path.dirname(__file__), package_dir)
# Allow unzipped packages to be imported
# from packages folder
sys.path.insert(0, package_dir_path)
# Append zip archives to path for zipimport
for filename in os.listdir(package_dir_path):
if filename.endswith((".zip", ".egg")):
sys.path.insert(0, "%s/%s" % (package_dir_path, filename))
from wsgiref.handlers import CGIHandler
from application.settings import DEBUG_MODE
from application import app
def main():
if DEBUG_MODE:
# Run debugged app
from werkzeug_debugger_appengine import get_debugged_app
app.debug=True
debugged_app = get_debugged_app(app)
CGIHandler().run(debugged_app)
else:
# Run production app
from google.appengine.ext.webapp.util import run_wsgi_app
run_wsgi_app(app)
# Use App Engine app caching
if __name__ == "__main__":
main()