Esempio 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
Esempio 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
Esempio 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)
Esempio n. 4
0
def register_extensions(app):
    """Register Flask extensions."""
    bcrypt.init_app(app)
    db.init_app(app)
    migrate.init_app(app, db)
    cors.init_app(app)
    ma.init_app(app)
    return None
Esempio n. 5
0
def register_extensions(app):
    """Register Flask extensions."""
    api.init_app(app)
    bcrypt.init_app(app)
    db.init_app(app)
    mail.init_app(app)
    migrate.init_app(app, db)
    return None
Esempio n. 6
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
Esempio n. 7
0
def create_app(config='develop'):
    """App factory."""
    app = Flask(
        __name__,
        static_folder='../static',
        static_url_path='/static-native',
    )
    config = configs[config]
    app.config.from_object(config)
    db.init_app(app)
    ma.init_app(app)
    migrate.init_app(app, db)
    mail.init_app(app)
    passlib.init_app(app)

    from server.handlers import register_handlers
    register_handlers(app)

    register_blueprints(app)

    data.module_data = load_modules(getattr(config(), "MODULE_FILE_PATH"))
    data.research_data = load_research(getattr(config(), "RESEARCH_FILE_PATH"))

    return app
Esempio n. 8
0
def register_extensions(app):
    cors.init_app(app)
    db.init_app(app)
    ma.init_app(app)
    migrate.init_app(app, db)