-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
33 lines (27 loc) · 789 Bytes
/
server.py
File metadata and controls
33 lines (27 loc) · 789 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
import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.middleware.gzip import GZipMiddleware
from config.settings import App, Cors
from source.routes import example
app = FastAPI()
# middleware
app.add_middleware(GZipMiddleware)
app.add_middleware(
CORSMiddleware,
allow_origins=Cors.allow_origins,
allow_methods=Cors.allow_methods,
allow_headers=Cors.allow_headers,
allow_credentials=True,
)
app.include_router(example.router, prefix="/examples", tags=["Examples"])
# add other routes here
if __name__ == "__main__":
uvicorn.run(
"server:app",
host=App.host,
port=App.port,
log_config=uvicorn.config.LOGGING_CONFIG,
proxy_headers=True,
reload=App.dev,
)