diff --git a/web_server.py b/web_server.py index 7354180..a429e72 100644 --- a/web_server.py +++ b/web_server.py @@ -28,8 +28,11 @@ class CommandRequest(BaseModel): @app.post("/command") async def command(req: CommandRequest): - response = await process(req.text) - return {"response": response} + try: + response = await process(req.text) + return {"response": response} + except Exception as e: + return JSONResponse(status_code=500, content={"response": f"Erreur : {e}"}) @app.get("/status") diff --git a/wireclaw_core.py b/wireclaw_core.py index abafb63..8e44a00 100644 --- a/wireclaw_core.py +++ b/wireclaw_core.py @@ -96,7 +96,7 @@ async def interpret_command(text): async def execute_command(drone, cmd): global drone_armed action = cmd.get("action") - alt = float(cmd.get("altitude", 15)) + alt = float(cmd.get("altitude") or 15) msg = cmd.get("message", "OK") if action == "position":