Esempio n. 1
0
def create_base_app(config):
    """Init configuration and extensions"""
    app = Flask(__name__)
    app.config.from_object(config)
    config.init_app(app)

    app._logger = init_logger(syslogtag=app.config['LOGGER_SYSLOGTAG'],
                              logger_name=app.config['LOGGER_NAME'])

    marshmallow.init_app(app)
    db.init_app(app)

    if app.config['DEBUG']:
        admin_extension.init_app(app)
        debug_toolbar.init_app(app)

    login_manager.init_app(app)
    login_manager.anonymous_user = Anonymous
    # Change these views to fit your app.
    # Use flask_truss.auth.attempt_login to login a user.
    login_manager.login_view = "auth.login"
    login_manager.refresh_view = "auth.login"
    login_manager.login_message = "You do not have access to that page."
    login_manager.user_loader(load_user)

    return app
Esempio n. 2
0
def create_base_app(config):
    """Init configuration and extensions"""
    app = Flask(__name__)
    app.config.from_object(config)
    config.init_app(app)

    app._logger = init_logger(syslogtag=app.config['LOGGER_SYSLOGTAG'],
                              logger_name=app.config['LOGGER_NAME'])

    marshmallow.init_app(app)
    db.init_app(app)

    if app.config['DEBUG']:
        admin_extension.init_app(app)
        debug_toolbar.init_app(app)

    login_manager.init_app(app)
    login_manager.anonymous_user = Anonymous
    # Change these views to fit your app.
    # Use flask_truss.auth.attempt_login to login a user.
    login_manager.login_view = "auth.login"
    login_manager.refresh_view = "auth.login"
    login_manager.login_message = "You do not have access to that page."
    login_manager.user_loader(load_user)

    return app
Esempio n. 3
0
def create_base_app(config):
    """Init configuration and extensions"""
    app = Flask(__name__)
    app.config.from_object(config)
    config.init_app(app)

    file_handler = SysLogHandler()
    file_handler.setLevel(logging.WARNING)
    app.logger.addHandler(file_handler)

    db.init_app(app)
    bcrypt.init_app(app)

    if app.config['DEBUG']:
        admin_extension.init_app(app)
        debug_toolbar.init_app(app)

    login_manager.init_app(app)
    login_manager.anonymous_user = Anonymous
    # Change these views to fit your app
    login_manager.login_view = "auth.login"
    login_manager.refresh_view = "auth.login"
    login_manager.login_message = "You do not have access to that page."
    login_manager.user_loader(load_user)

    app.json_encoder = CustomJSONEncoder

    return app