-
Notifications
You must be signed in to change notification settings - Fork 45
/
manage.py
32 lines (23 loc) · 918 Bytes
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from application.initializer import IncludeAPIRouter
from application.main.config import settings
def get_application():
_app = FastAPI(title=settings.API_NAME,
description=settings.API_DESCRIPTION,
version=settings.API_VERSION)
_app.include_router(IncludeAPIRouter())
_app.add_middleware(
CORSMiddleware,
allow_credentials=False,
allow_methods=["*"],
allow_headers=["*"],
)
return _app
app = get_application()
@app.on_event("shutdown")
async def app_shutdown():
# on app shutdown do something probably close some connections or trigger some event
print("On App Shutdown i will be called.")
#uvicorn.run("manage:app", host=settings.HOST, port=settings.PORT, log_level=settings.LOG_LEVEL, use_colors=True,reload=True)