コード例 #1
0
def register_views(flask_app: Flask):
    from app.views import route

    handle_exception_func = flask_app.handle_exception
    handle_user_exception_func = flask_app.handle_user_exception
    # register_blueprint 시 defer되었던 함수들이 호출되며, flask-restful.Api._init_app()이 호출되는데
    # 해당 메소드가 app 객체의 에러 핸들러를 오버라이딩해서, 별도로 적용한 handler의 HTTPException 관련 로직이 동작하지 않음
    # 따라서 두 함수를 임시 저장해 두고, register_blueprint 이후 함수를 재할당하도록 함

    route(flask_app)

    flask_app.handle_exception = handle_exception_func
    flask_app.handle_user_exception = handle_user_exception_func
コード例 #2
0
def create_app(*config_cls):
    app = Flask(__name__)

    for config in config_cls:
        app.config.from_object(config)

    route(app)
    db.connect()

    from app.models import BaseModel
    db.create_tables(BaseModel.__subclasses__())

    return app
コード例 #3
0
ファイル: __init__.py プロジェクト: SangminOut/But
def create_app(*config_cls) -> Flask:
    print('[INFO] Flask application initialized with {}'.format(
        [config.__name__ for config in config_cls]))

    app_ = Flask(__name__)

    for config in config_cls:
        app_.config.from_object(config)

    Swagger(template=app_.config['SWAGGER_TEMPLATE']).init_app(app_)

    connect(**app_.config['MONGODB_SETTINGS'])
    route(app_)

    return app_
コード例 #4
0
def register_views(flask_app: Flask):
    from app.views import route

    route(flask_app)
コード例 #5
0
def register_views(sanic_app: Sanic):
    from app.views import route

    route(sanic_app)
コード例 #6
0
def register_controls(flask_app):
    from app.views import route

    route(flask_app)