-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
37 lines (26 loc) · 779 Bytes
/
Copy pathapp.py
File metadata and controls
37 lines (26 loc) · 779 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 fastapi
from fastapi_utk.middleware import CamelCaseQueryParamsMiddleware
from fastapi_utk.openapi import translate_query_params_snake_to_camel
from routes.router import root_router
HOST = "127.0.0.1"
PORT = 8000
def create_app() -> fastapi.FastAPI:
fastapi_app = fastapi.FastAPI()
fastapi_app.include_router(root_router)
# Swagger
fastapi_app.openapi_schema = translate_query_params_snake_to_camel(
fastapi_app.openapi(),
)
# Middlewares
fastapi_app.add_middleware(CamelCaseQueryParamsMiddleware)
return fastapi_app
if __name__ == "__main__":
import uvicorn
try:
uvicorn.run(
app=create_app(),
host=HOST,
port=PORT,
)
except KeyboardInterrupt:
...