this is a push

This commit is contained in:
2026-08-13 15:03:34 +08:00
parent 0f55259fff
commit ca61c132f2
109 changed files with 44036 additions and 198 deletions

View File

@@ -44,7 +44,7 @@ app = FastAPI(title="Smoke Fire Detector API", version="0.1.0")
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_methods=["GET", "POST", "DELETE"],
allow_methods=["GET", "POST", "PATCH", "DELETE"],
allow_headers=["*"],
)
@@ -171,6 +171,33 @@ def list_events(
}
@app.get("/api/robots")
def list_robots() -> dict[str, Any]:
robots = ALERT_MANAGER.channel_status
return {
"robots": robots,
"summary": {
"total": len(robots),
"configured": sum(robot["configured"] for robot in robots),
"delivered": sum(robot["delivered"] for robot in robots),
"failed": sum(robot["failed"] for robot in robots),
},
}
@app.post("/api/robots/{channel}/test")
def test_robot(channel: str) -> dict[str, Any]:
try:
robot = ALERT_MANAGER.test_channel(channel)
except ValueError as error:
raise HTTPException(status_code=400, detail=str(error)) from error
except RuntimeError as error:
raise HTTPException(
status_code=502,
detail=f"机器人消息发送失败: {error}",
) from error
return {"status": "sent", "robot": robot}
@app.patch("/api/events/{event_id}")
def update_event(
event_id: str,
@@ -191,6 +218,7 @@ def dashboard() -> dict[str, Any]:
"summary": EVENT_STORE.summary(),
"recent_events": EVENT_STORE.list(limit=6),
"system": health(),
"robots": list_robots(),
"detection": {
"confidence": CONFIDENCE,
"iou": IOU,