Пример #1
0
def install_all_routes(app: Flask) -> None:
    from pcapi.admin.install import install_admin_autocomplete_views
    from pcapi.admin.install import install_admin_template_filters
    from pcapi.admin.install import install_admin_views
    from pcapi.flask_app import admin
    from pcapi.models import db
    from pcapi.routes.adage.v1.blueprint import adage_v1
    from pcapi.routes.adage_iframe.blueprint import adage_iframe
    from pcapi.routes.native.v1.blueprint import native_v1
    from pcapi.routes.pro.blueprints import pro_api_v2
    from pcapi.routes.saml.blueprint import saml_blueprint
    import pcapi.tasks
    from pcapi.tasks.decorator import cloud_task_api

    install_admin_views(admin, db.session)
    install_admin_autocomplete_views()
    install_routes(app)
    pcapi.tasks.install_handlers(app)
    install_admin_template_filters(app)

    app.register_blueprint(adage_v1, url_prefix="/adage/v1")
    app.register_blueprint(native_v1, url_prefix="/native/v1")
    app.register_blueprint(pro_api_v2, url_prefix="/v2")
    app.register_blueprint(adage_iframe, url_prefix="/adage-iframe")
    app.register_blueprint(saml_blueprint, url_prefix="/saml")
    app.register_blueprint(cloud_task_api)
Пример #2
0
def app():
    app = Flask(  # pylint: disable=redefined-outer-name
        __name__,
        template_folder=Path(pcapi.__path__[0]) / "templates",
    )

    app.config["SQLALCHEMY_DATABASE_URI"] = settings.DATABASE_URL_TEST
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
    app.config["SECRET_KEY"] = "@##&6cweafhv3426445"
    app.config["REMEMBER_COOKIE_HTTPONLY"] = False
    app.config["SESSION_COOKIE_HTTPONLY"] = False
    app.config["TESTING"] = True
    app.url_map.strict_slashes = False
    app.json_encoder = EnumJSONEncoder

    login_manager = LoginManager()
    login_manager.init_app(app)
    db.init_app(app)

    app.app_context().push()
    install_database_extensions(app)

    run_migrations()

    install_activity()
    install_routes(app)
    install_local_providers()
    admin.init_app(app)
    install_admin_views(admin, db.session)

    app.mailjet_client = Mock()
    app.redis_client = Mock()
    app.register_blueprint(native_v1, url_prefix="/native/v1")

    JWTManager(app)

    return app
Пример #3
0
    profiling_restrictions = [settings.PROFILE_REQUESTS_LINES_LIMIT]
    app.config["PROFILE"] = True
    app.wsgi_app = ProfilerMiddleware(app.wsgi_app,
                                      restrictions=profiling_restrictions)


def install_login_manager() -> None:
    # pylint: disable=unused-import
    import pcapi.utils.login_manager


with app.app_context():
    if settings.IS_DEV:
        install_activity()
        install_local_providers()
        install_features()

    install_login_manager()
    install_documentation()
    install_admin_views(admin, db.session)
    install_routes(app)

    app.register_blueprint(native_v1, url_prefix="/native/v1")

if __name__ == "__main__":
    port = settings.FLASK_PORT
    app.run(host="0.0.0.0",
            port=port,
            debug=settings.IS_DEV,
            use_reloader=True)