File size: 512 Bytes
e317d56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import time

from fastapi import APIRouter

from src.api.state import get_state

router = APIRouter(tags=["Health"])


@router.get("/health")
async def health_check():
    state = get_state()
    service = state["service"]
    uptime = 0.0
    if state["startup_time"]:
        uptime = round(time.time() - state["startup_time"], 1)
    return {
        "status": "ok" if service else "loading",
        "model": state["model_name"],
        "uptime_s": uptime,
        "project": "youtube_hate_detector",
    }