# Standard library imports from os import getenv # First-party imports from application import create_application application = create_application(getenv('ENVIRONMENT', default='production')) application.app_context().push() if __name__ == '__main__': application.run(port=80)
import os from application import create_application application = create_application(os.environ.get("INSTANCE_PATH"))
def application(): application = create_application(os.environ.get("INSTANCE_PATH")) application.testing = True return application
#coding:utf-8 import sys from flask import Flask import os from application import create_application from celery import Celery sys.path.append(os.getcwd() + "/../") app = Flask(__name__) app.config["CELERY_BROKER_URL"] = "redis://localhost:6379/0" app.config["CELERY_RESULT_BACKEND"] = "redis://localhost:6379/0" create_application(app) celery = Celery(app.name, broker=app.config["CELERY_BROKER_URL"]) celery.config.update(app.config) # def init_celery(app): # celery = Celery(app.import_name, broker=app.config["CELERY_BROKER_URL"]) # celery.config.update(app.config) # TaskBase = celery.Task # class ContextTask(TaskBase): # abstract = True # def __call__(self, *args, **kwargs): # with app.app_context(): # return TaskBase.__call__(self, args, kwargs) # celery.Task = ContextTask # return celery if __name__ == "__main__":
from application import create_application import webapp2 app = create_application() # TODO, debug=False! application = webapp2.WSGIApplication(app.urls.handler_list(), debug=True)
def application_client(): application = create_application() application.config['TESTING'] = True client = application.test_client() return client
from application import create_application if __name__ == '__main__': app = create_application() app.run(host="0.0.0.0", port=80)
#coding:utf-8 import sys from flask import Flask import os from application import create_application from celery import Celery sys.path.append(os.getcwd() + "/../") app = Flask(__name__) app.config["CELERY_BROKER_URL"] = "redis://localhost:6379/0" app.config["CELERY_RESULT_BACKEND"] = "redis://localhost:6379/0" create_application(app) celery = Celery(app.name, broker=app.config["CELERY_BROKER_URL"]) celery.config.update(app.config) # def init_celery(app): # celery = Celery(app.import_name, broker=app.config["CELERY_BROKER_URL"]) # celery.config.update(app.config) # TaskBase = celery.Task # class ContextTask(TaskBase): # abstract = True # def __call__(self, *args, **kwargs): # with app.app_context(): # return TaskBase.__call__(self, args, kwargs) # celery.Task = ContextTask # return celery