32 lines
655 B
Python
32 lines
655 B
Python
from fastapi import APIRouter
|
|
from config import get_config, save_config, load_config, AppConfig
|
|
|
|
router = APIRouter(prefix="/api")
|
|
|
|
|
|
@router.get("/config")
|
|
async def get_configuration():
|
|
config = get_config()
|
|
return config.model_dump()
|
|
|
|
|
|
@router.put("/config")
|
|
async def update_configuration(data: AppConfig):
|
|
save_config(data)
|
|
return {"status": "ok"}
|
|
|
|
|
|
@router.post("/config/reload")
|
|
async def reload_configuration():
|
|
load_config()
|
|
return {"status": "ok"}
|
|
|
|
|
|
@router.get("/health")
|
|
async def health_check():
|
|
from mqtt_bridge import get_mqtt_status
|
|
return {
|
|
"status": "ok",
|
|
"mqtt": get_mqtt_status(),
|
|
}
|