Esempio n. 1
0
def create_app(app_name=APP_NAME, test_config=None, **kwargs):
    """
    Function which creates Flask app instance and initializes database, API, and celery when given celery argument.
    Only celery worker calls this function without celery argument given, for its purpose of having its own instances.
    :param app_name: Application name. Can be set in definitions file.
    :param test_config: -
    :param kwargs: keyword arguments which may contain 'celery' key with celery app instance as argument.
    :return: Flask app instance
    """
    app = Flask(app_name)
    if kwargs.get("celery"):
        init_celery(kwargs.get("celery"), app)

    if test_config:
        app.config.update(test_config)
    else:
        app.config.from_mapping(
            SQLALCHEMY_DATABASE_URI=SQLALCHEMY_DB_URI,
            SQLALCHEMY_TRACK_MODIFICATIONS=SQLALCHEMY_TRACK_MODIFICATIONS,
        )

    with app.app_context():
        init_database(app)
        api.init_app(app)

    return app
Esempio n. 2
0
def create_app(app_name, **kwargs):
    app = Flask(app_name)
    if kwargs.get("celery"):
        init_celery(kwargs.get("celery"), app)
    from app.routes import bp
    app.register_blueprint(bp)
    print("Reached")
    return app
Esempio n. 3
0
def create_app(app_name=PKG_NAME, **kwargs):

    app = Flask(app_name)
    app.config.from_object(config['flask'][os.environ['FLASK_ENV']])

    if kwargs.get("celery"):
        init_celery(kwargs.get("celery"), app)
    from app.machine_learning import machine_learning_bp
    app.register_blueprint(machine_learning_bp)

    @app.route('/')
    def check():
        return 'Helloworld'

    return app
from app import *
from app.factory import create_app, init_app
from app.celery_utils import init_celery

app, jwtManager = create_app()
app = init_app(app)
init_celery(celery_instance, app)
Esempio n. 5
0
from app import celery
from app.factory import create_app
from app.celery_utils import init_celery

app = create_app()
init_celery(celery, app)