-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
41 lines (31 loc) · 925 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
34
35
36
37
38
39
40
41
"""
This file is the entry point for the FastAPI application.
It configures middleware, adds sub-routers, and defines application-level health checks.
"""
from fastapi import APIRouter, FastAPI
from apis import devices, push
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI()
# Configure as needed
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Allows all origins
allow_credentials=True,
allow_methods=["*"], # Allows all methods
allow_headers=["*"], # Allows all headers
)
# List of routers
routers: list[APIRouter] = [devices.router, push.router]
# Add routers to app
for router in routers:
app.include_router(router)
# Application-Level Health Checks
@app.get("/health")
async def health():
return {"message": "OK"}
@app.get("/")
async def root():
return {"message": "Hello World"}
if __name__ == "__main__":
import uvicorn
uvicorn.run(app)