Created
October 15, 2011 09:49
-
-
Save tokuda109/1289338 to your computer and use it in GitHub Desktop.
main.py of my GAE/Py project.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import os, sys | |
#: The reason is write at below page: | |
#: http://code.google.com/p/appengine-monkey/issues/detail?id=25#c3 | |
os.mkdir = None | |
ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) | |
APP_PATH = os.path.join(ROOT_PATH, 'application') | |
LIB_PATH = os.path.join(ROOT_PATH, 'lib') | |
if APP_PATH not in sys.path: | |
sys.path.insert(0, APP_PATH) | |
if LIB_PATH not in sys.path: | |
sys.path.insert(0, LIB_PATH) | |
#: Append zip archives to path for zipimport | |
try: | |
zip_files = [ | |
'flask.zip', | |
'httplib2.zip', | |
'jinja2.zip', | |
'oauth2.zip', | |
'werkzeug.zip', | |
'wtforms.zip' | |
] | |
for zip_file in zip_files: | |
zip_path = os.path.join(LIB_PATH, zip_file) | |
if os.path.exists(zip_path): | |
sys.path.insert(0, zip_path) | |
except: | |
sys.stderr.write("Error: Tried importing third-party files.") | |
raise | |
from google.appengine.ext.webapp.util import run_wsgi_app | |
from application import app | |
from settings import DEBUG | |
def main(): | |
if DEBUG: | |
# In development environment, run debugged app instead of production app. | |
from werkzeug.debug import DebuggedApplication | |
debugged_app = DebuggedApplication(app, evalex=True) | |
# Run debugged app | |
run_wsgi_app(debugged_app) | |
else: | |
# Run production app | |
run_wsgi_app(app) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment