lightning / status.py
sharktide's picture
Update status.py
1cd5b11 verified
# status.py
from fastapi import APIRouter, Response
from fastapi.responses import JSONResponse
router = APIRouter(prefix="/status")
@router.head("/sfx")
async def head_sfx():
return Response(
status_code=200,
headers={
"Content-Type": "audio/mpeg",
"Accept-Ranges": "bytes",
},
)
@router.head("/image")
async def head_image():
return Response(
status_code=200,
headers={
"Content-Type": "image/jpeg",
"Accept-Ranges": "bytes",
},
)
@router.head("/video")
async def head_video():
return Response(
status_code=200,
headers={
"Content-Type": "video/mp4",
"Accept-Ranges": "bytes",
},
)
@router.head("/text")
async def head_text():
return Response(
status_code=200,
headers={
"Content-Type": "application/json",
"Accept-Ranges": "bytes",
},
)
@router.get("/")
async def get_status():
notify = ""
services = {
"Video Generation": {"code": 200, "state": "ok", "message": "Running Normally"},
"Image Generation": {"code": 200, "state": "ok", "message": "Running Normally"},
"Lightning-Text v2": {"code": 200, "state": "ok", "message": "Running normally"},
"Music/SFX Generation": {"code": 200, "state": "ok", "message": "Running normally"},
}
overall_state = (
"ok" if all(s["state"] == "ok" for s in services.values()) else "degraded"
)
return JSONResponse(
status_code=200,
content={
"state": overall_state,
"services": services,
"notifications": notify,
"latest": "2.11.0",
},
)