-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
33 lines (24 loc) · 791 Bytes
/
main.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
33
import uvicorn
import asyncio
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.api.routers import v1
from app.core.project_config import settings
from app.core.database import init_models
def get_application() -> FastAPI:
application = FastAPI(
title=settings.PROJECT_NAME, debug=settings.DEBUG, version=settings.VERSION
)
application.include_router(v1)
application.add_middleware(
CORSMiddleware,
allow_origins=settings.CORS_ALLOWED_ORIGINS,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
return application
app = get_application()
if __name__ == "__main__":
asyncio.run(init_models())
uvicorn.run("main:app", host="127.0.0.1", reload=True)