def real_main(): wsgi_app = request_cache.RequestCacheMiddleware(api_app) wsgi_app = profiler.ProfilerWSGIMiddleware(wsgi_app) wsgi_app = middleware.GAEBingoWSGIMiddleware(wsgi_app) if App.is_dev_server: try: # Run debugged app from werkzeug_debugger_appengine import get_debugged_app api_app.debug = True debugged_app = get_debugged_app(wsgi_app) CGIHandler().run(debugged_app) return debugged_app except Exception, e: api_app.debug = False logging.warning( "Error running debugging version of werkzeug app, running production version: %s" % e)
class ShowJson(request_handler.RequestHandler): @user_util.open_access def get(self, language, namespace): try: with open('./locale/' + language + "/" + namespace + ".json") as file: #Open JSON file and return it self.response.out.write(file.read()) self.response.headers['Content-Type'] = "application/json" except IOError as e: self.response.out.write("{}") application = webapp2.WSGIApplication([ ('/locale/(.*)/(.*)', ShowJson), ], debug=True) application = profiler.ProfilerWSGIMiddleware(application) application = GAEBingoWSGIMiddleware(application) application = request_cache.RequestCacheMiddleware(application) application = wsgi_compat.WSGICompatHeaderMiddleware(application) def main(): run_wsgi_app(application) if __name__ == '__main__': main()