-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
37 lines (29 loc) · 803 Bytes
/
Copy pathmain.py
File metadata and controls
37 lines (29 loc) · 803 Bytes
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
34
35
36
37
import asyncio
import uvicorn
import fastapi
from starlette.middleware.cors import CORSMiddleware
from src.config.config import settings
async def start() -> None:
"""
start of all processes
:return: None
"""
app = fastapi.FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
config = uvicorn.Config(app=app,
host=settings.HOST,
port=settings.PORT,
loop="asyncio")
server = uvicorn.Server(config=config)
await asyncio.gather(server.serve())
if "__main__" == __name__:
try:
asyncio.run(start())
except KeyboardInterrupt:
pass