Beispiel #1
0
def create_app(name=__name__, **kwargs):

    # create app and load configuration variables
    app = Flask(name, instance_relative_config=False)
    app.config.from_object(Config)
    app.context = Context

    # initialize logging
    init_logging(**kwargs)

    # configure headers
    CORS(app)

    with app.app_context():
        # configure database
        app.db = db
        db.init_app(app)
        migrate.init_app(app, db)

        # configure imports
        init_models(app)
        init_schemas(app)

        # configure celery
        app.redis = redis_db
        init_celery(app, celery)
        load_tasks()

        # configure views
        compress.init_app(app)
        init_views(app)

    # configure developer tools
    Context.register(app, db, celery)
    Cli.register(app, db, celery)

    return app
Beispiel #2
0
import os

from application import cli, create_app
from config import configs

config_name = os.getenv('FLASK_ENV') or 'default'
app = create_app(configs[config_name])
cli.register(app)

if __name__ == '__main__':
    app.run()
Beispiel #3
0
"""This is the routing file - all pages of website will be directed from here"""
from application import create_app, cli

# Create the flask application
flask_app = create_app()

# Register custom CLI commands
cli.register(flask_app)

if __name__ == "__main__":
    flask_app.run(host='127.0.0.1', port=80)