-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
39 lines (26 loc) · 824 Bytes
/
Copy pathmain.py
File metadata and controls
39 lines (26 loc) · 824 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
38
39
from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from database import init_db
from routers import analysis, shipments
@asynccontextmanager
async def lifespan(app: FastAPI):
init_db()
yield
app = FastAPI(title="ColdTrace API", version="1.0.0", lifespan=lifespan)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
API_PREFIX = "/api/v1"
app.include_router(shipments.router, prefix=API_PREFIX)
app.include_router(analysis.router, prefix=API_PREFIX)
@app.get("/")
def root():
return {"message": "ColdTrace API is running", "docs": "/docs"}
@app.get(f"{API_PREFIX}/health")
def health():
return {"status": "ok", "version": "1.0.0"}