import os import sys import webapp2 try: from google.appengine.api import urlfetch urlfetch.set_default_fetch_deadline(10) except ImportError: pass lib_path = os.path.normpath(os.path.join(os.path.dirname(__file__), "..", "lib")) for dir_path in os.listdir(lib_path): sys.path.insert(0, os.path.join(lib_path, dir_path)) from application.utils import monkey_patch monkey_patch.patch_all() config = dict((name, os.environ[name]) for name in ( "CONSUMER_KEY", "CONSUMER_SECRET", "SECRET_KEY", )) app = webapp2.WSGIApplication([ webapp2.Route("/", handler="application.views.login.Login", name="login"), webapp2.Route("/rss/<sid>", handler="application.views.rss.RSS", name="rss"), webapp2.Route("/proxy/<url>/<md5hash>", handler="application.views.proxy.Proxy", name="proxy"), ], config=config, debug=True)
app = flask.Flask("application") # Config from os.environ are all strings, but here only accepts integer. app.config["PERMANENT_SESSION_LIFETIME"] = 31536000 # one year current_version_name = modules.get_current_version_name() # import all configs from app.yaml os_names = ( "SITE_NAME", "SESSION_COOKIE_PATH", "CONSUMER_KEY", "CONSUMER_SECRET", "SECRET_KEY", ) for name in os_names: name_with_version = name + "_V" + current_version_name if name_with_version not in os.environ: name_with_version = name logging.debug("load config %s from %s", name, name_with_version) app.config[name] = os.environ[name_with_version] app.config["TWIP_T_MODE"] = os.environ.get("TWIP_T_MODE", None) from application.utils import monkey_patch monkey_patch.patch_all(app) from application import views from application import routes