Example #1
0
def make_application():
    app = FastAPI(title=config.PROJECT_NAME, version=config.VERSION)
    app.add_middleware(CORSMiddleware,
                       allow_origins=["*"],
                       allow_headers=["*"],
                       allow_methods=["*"],
                       allow_credentials=True)
    app.add_event_handler("startup", tasks.create_start_app_handler(app))
    app.add_event_handler("shutdown", tasks.create_stop_app_handler(app))

    app.include_router(api_router, prefix="/api")
    return app
Example #2
0
def get_application():
    app = FastAPI(title=config.PROJECT_NAME, version=config.VERSION)
    app.add_middleware(
        CORSMiddleware,
        allow_origins=["*"],
        allow_credentials=True,
        allow_methods=["*"],
        allow_headers=["*"],
    )

    app.add_event_handler("startup", tasks.create_start_app_handler(app))
    app.add_event_handler("shutdown", tasks.create_stop_app_handler(app))

    app.add_exception_handler(NotImplementedError, not_implemented_exception_handler)

    app.include_router(router)
    app.include_router(api_router, prefix=config.API_PREFIX)

    return app
Example #3
0
def get_application():
    app = FastAPI(title=config.PROJECT_NAME, version=config.VERSION)

    app.add_middleware(
        CORSMiddleware,
        allow_origins=["*"],
        allow_credentials=True,
        allow_methods=["*"],
        allow_headers=["*"],
    )

    @app.get('/')
    def index():
        return f"Welcome to the {config.PROJECT_NAME}. Go to 127.0.0.1:8000/docs for more information about the API"

    app.add_event_handler("startup", tasks.create_start_app_handler(app))
    app.add_event_handler("shutdown", tasks.create_stop_app_handler(app))

    app.include_router(api_router, prefix="/api")
    return app
Example #4
0
def bind_event_handlers(app: FastAPI):
    """
        bind start/stop handlers
    """
    app.add_event_handler("startup", tasks.create_start_app_handler(app))
    app.add_event_handler("shutdown", tasks.create_stop_app_handler(app))