Files
Remote-Terminal-for-MeshCore/app/routers/health.py
T
Jack Kingsman 557cb12879 Initial commit
2026-01-06 20:02:48 -08:00

24 lines
601 B
Python

from fastapi import APIRouter
from pydantic import BaseModel
from app.radio import radio_manager
router = APIRouter(tags=["health"])
class HealthResponse(BaseModel):
status: str
radio_connected: bool
serial_port: str | None
@router.get("/health", response_model=HealthResponse)
async def healthcheck() -> HealthResponse:
"""Check if the API is running and if the radio is connected."""
return HealthResponse(
status="ok" if radio_manager.is_connected else "degraded",
radio_connected=radio_manager.is_connected,
serial_port=radio_manager.port,
)