示例#1
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
示例#2
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
示例#3
0
文件: app.py 项目: kaigezhang/pdano
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)
示例#4
0
文件: app.py 项目: nebrasoftware/alen
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
示例#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
示例#6
0
 def wrapper(*args, **kw):
     app = Flask(__name__)
     app_settings = os.getenv(
         'APP_SETTINGS', 'server.config.GettingDataForModelsConfig')
     app.config.from_object(app_settings)
     db.init_app(app)
     with app.app_context():
         return func(*args, **kw)
示例#7
0
def register_extensions(app):
    bootstrap.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    mail.init_app(app)
    dropzone.init_app(app)
    moment.init_app(app)
    whooshee.init_app(app)
    avatars.init_app(app)
    csrf.init_app(app)
示例#8
0
def get_celery_app_with_db():
    flask_app = Flask(__name__,
                      template_folder='../../client/templates',
                      static_folder='../../client/static')

    app_settings = os.getenv('APP_SETTINGS', 'server.config.CeleryConfig')
    flask_app.config.from_object(app_settings)
    celery = make_celery(flask_app)
    db.init_app(flask_app)
    mail.init_app(flask_app)
    return celery
示例#9
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
示例#10
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
示例#11
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
示例#12
0
def extensions(app):
    db.init_app(app)
    comment_api.init_app(app)
    user_api.init_app(app)
示例#13
0
def register_extensions(app):
    cors.init_app(app)
    db.init_app(app)
    ma.init_app(app)
    migrate.init_app(app, db)
示例#14
0
def setup_extensions(app):
    db.init_app(app)
    cache.init_app(app)
    bcrypt.init_app(app)
    cors.init_app(app)
    setup_logger(app)
示例#15
0
def register_extensions(app):
    cors.init_app(app)
    rest_api.init_app(app)
    db.init_app(app)

    return None