mgbam commited on
Commit
eee1f4d
·
verified ·
1 Parent(s): b9a9c97

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +35 -0
main.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from fastapi.middleware.cors import CORSMiddleware
3
+
4
+ from app.api import ecg, streaming, dashboard
5
+ from app.db.session import close_engine, init_db
6
+
7
+ app = FastAPI(title="Sundew Health API", version="0.1.0")
8
+
9
+ app.add_middleware(
10
+ CORSMiddleware,
11
+ allow_origins=["*"],
12
+ allow_credentials=True,
13
+ allow_methods=["*"],
14
+ allow_headers=["*"],
15
+ )
16
+
17
+
18
+ @app.on_event("startup")
19
+ def on_startup() -> None:
20
+ init_db()
21
+
22
+
23
+ @app.on_event("shutdown")
24
+ def on_shutdown() -> None:
25
+ close_engine()
26
+
27
+
28
+ @app.get("/health", tags=["meta"])
29
+ async def health_check() -> dict:
30
+ return {"status": "ok"}
31
+
32
+
33
+ app.include_router(ecg.router, prefix="/ecg", tags=["ecg"])
34
+ app.include_router(streaming.router, tags=["streaming"])
35
+ app.include_router(dashboard.router, prefix="/dashboard", tags=["dashboard"])