Example #1
0
def create_app(env='PROD'):
    app = Flask(__name__)

    if env.lower() == 'prod':
        app.config.from_object(ProdSettings())
    elif env.lower() == 'test':
        app.config.from_object(TestSettings())
    else:
        raise ValueError('Unknown environment: %s' % (env,))

    init_log()

    app.register_blueprint(api_blueprint)
    app.register_blueprint(public_blueprint)
    app.register_blueprint(ws_blueprint)

    app.jinja_env.auto_reload = True
    app.config['TEMPLATES_AUTO_RELOAD'] = True

    # Stop the app from initializing twice in debug mode.
    #    if not app.debug or os.environ.get("WERKZEUG_RUN_MAIN") == "true":
    # The app is not in debug mode or we are in the reloaded process
    init_database(app, tests=env.lower() == 'test')

    init_marshmallow(app)

    # init_scheduler(app)

    socketio = init_socketio(app)

    init_task_pool(socketio)

    return app
Example #2
0
def create_app(env='PROD'):
    app = Flask(__name__)

    if env.lower() == 'prod':
        app.config.from_object(ProdSettings())
    elif env.lower() == 'test':
        app.config.from_object(TestSettings())
    else:
        raise ValueError('Unknown environment: %s' % (env,))

    init_log(app)

    app.register_blueprint(api_blueprint)
    app.register_blueprint(public_blueprint)
    app.register_blueprint(ws_blueprint)

    app.jinja_env.auto_reload = True
    app.config['TEMPLATES_AUTO_RELOAD'] = True

    # Stop the app from initializing twice in debug mode.
    #    if not app.debug or os.environ.get("WERKZEUG_RUN_MAIN") == "true":
    # The app is not in debug mode or we are in the reloaded process
    init_database(app, tests=env.lower() == 'test')

    init_marshmallow(app)

    # Init connections, or all other startup inits that require active connections, will fail.
    init_connections()

    # TODO: For now as assume always in debug mode, so it doesn't execute the scheduler twice.
    #init_scheduler(app, True)

    socketio = init_socketio(app)

    init_task_pool(socketio)



    return app
Example #3
0
def create_app(env='PROD'):
    # app = Flask(__name__)

    if env.lower() == 'prod':
        app.config.from_object(ProdSettings())
    elif env.lower() == 'test':
        app.config.from_object(TestSettings())
    else:
        raise ValueError('Unknown environment: %s' % (env, ))

    init_log(app)

    app.register_blueprint(api_blueprint)
    app.register_blueprint(public_blueprint)
    app.register_blueprint(ws_blueprint)

    app.jinja_env.auto_reload = True
    app.config['TEMPLATES_AUTO_RELOAD'] = True

    # Stop the app from initializing twice in debug mode.
    #    if not app.debug or os.environ.get("WERKZEUG_RUN_MAIN") == "true":
    # The app is not in debug mode or we are in the reloaded process
    init_database(app, tests=env.lower() == 'test')

    init_marshmallow(app)

    # Init connections, or all other startup inits that require active connections, will fail.
    init_connections()

    # TODO: For now as assume always in debug mode, so it doesn't execute the scheduler twice.
    #init_scheduler(app, True)

    socketio = init_socketio(app)

    init_task_pool(socketio)

    return app