Spaces:
Sleeping
Sleeping
Create api/health.py
Browse files- app/api/health.py +21 -0
app/api/health.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import APIRouter, status
|
| 2 |
+
from pydantic import BaseModel
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class HealthCheck(BaseModel):
|
| 6 |
+
status: str = "OK"
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
health_router = APIRouter()
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@health_router.get(
|
| 13 |
+
"/healthz",
|
| 14 |
+
tags=["healthcheck"],
|
| 15 |
+
summary="Perform a Health Check",
|
| 16 |
+
response_description="Return HTTP Status Code 200 (OK)",
|
| 17 |
+
status_code=status.HTTP_200_OK,
|
| 18 |
+
response_model=HealthCheck,
|
| 19 |
+
)
|
| 20 |
+
def get_health() -> HealthCheck:
|
| 21 |
+
return HealthCheck(status="OK")
|