Exemplo n.º 1
0
def register_extensions(app):
    from server.extensions import (
        db,
        migrate,
        mail,
        babel,
        cors,
        jwt,
        cache,
        compress,
        swagger,
    )

    db.init_app(app)
    migrate.init_app(app, db)
    mail.init_app(app)
    babel.init_app(app)

    cors.init_app(
        app, resources={r"/api/*": {"origins": "*"}}, supports_credentials=True
    )
    jwt.init_app(app)
    cache.init_app(app)
    compress.init_app(app)
    swagger.init_app(app)

    # Return validation errors as JSON
    @app.errorhandler(422)
    @app.errorhandler(400)
    def handle_error(err):
        messages = err.data.get("messages", "Invalid request.")
        return jsonify({"message": messages["json"]}), 400
Exemplo n.º 2
0
def create_app(script_info=None,
               settings_name='server.config.DevelopmentConfig'):
    app = Flask(__name__,
                template_folder='../client/templates',
                static_folder='../client/static')

    app_settings = os.getenv('APP_SETTINGS', settings_name)
    app.config.from_object(app_settings)

    bcrypt.init_app(app)
    db.init_app(app)
    migrate.init_app(app, db)
    mail.init_app(app)
    jwt.init_app(app)

    register_errors(app)
    app.config.update({'OAUTH1_PROVIDER_ENFORCE_SSL': False})

    app.shell_context_processor({'app': app, 'db': db})
    api = init_api(app)
    api_urls(api)
    app.register_blueprint(google_blueprint)

    initialize_black_list_loader()

    return app
Exemplo n.º 3
0
def register_extensions(app):
    """Register Flask extensions."""
    bcrypt.init_app(app)
    cache.init_app(app)
    db.init_app(app)
    migrate.init_app(app, db)
    jwt.init_app(app)
Exemplo n.º 4
0
def extensions(app):
    """
    Register extensions.

    :param app: Flask application instance
    :return: None
    """
    debug_toolbar.init_app(app)
    mail.init_app(app)
    csrf.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    limiter.init_app(app)
    jwt.init_app(app)

    return None
Exemplo n.º 5
0
def create_app(config_class=Config):
    app = Flask(__name__)
    app.config.from_object(config_class)

    CORS(app,
         resources={r'/*': {
             'origins': app.config.get('FRONTEND_URL')
         }},
         supports_credentials=True)

    db.init_app(app)
    migrate.init_app(app, db)
    jwt.init_app(app)

    from server.errors import bp as errors_bp
    app.register_blueprint(errors_bp)

    from server.api_cocktail import bp as api_cocktail_bp
    app.register_blueprint(api_cocktail_bp)

    from server.api_user import bp as api_user_bp
    app.register_blueprint(api_user_bp)

    return app
Exemplo n.º 6
0
def register_extensions(app, testing=False):

    jwt.init_app(app)
    cors.init_app(app)
    cache.init_app(app)
    api.init_app(app)