Fix TypeError altitude null + erreurs affichées dans l'UI
- float(cmd.get("altitude") or 15) : gère altitude=null retourné
par Gemini pour les commandes sans altitude (land, rtl, status…)
- /command attrape les exceptions et retourne JSON 500 avec le
message d'erreur, évite le "Erreur réseau" opaque dans la page
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@ -28,8 +28,11 @@ class CommandRequest(BaseModel):
|
|||||||
|
|
||||||
@app.post("/command")
|
@app.post("/command")
|
||||||
async def command(req: CommandRequest):
|
async def command(req: CommandRequest):
|
||||||
|
try:
|
||||||
response = await process(req.text)
|
response = await process(req.text)
|
||||||
return {"response": response}
|
return {"response": response}
|
||||||
|
except Exception as e:
|
||||||
|
return JSONResponse(status_code=500, content={"response": f"Erreur : {e}"})
|
||||||
|
|
||||||
|
|
||||||
@app.get("/status")
|
@app.get("/status")
|
||||||
|
|||||||
@ -96,7 +96,7 @@ async def interpret_command(text):
|
|||||||
async def execute_command(drone, cmd):
|
async def execute_command(drone, cmd):
|
||||||
global drone_armed
|
global drone_armed
|
||||||
action = cmd.get("action")
|
action = cmd.get("action")
|
||||||
alt = float(cmd.get("altitude", 15))
|
alt = float(cmd.get("altitude") or 15)
|
||||||
msg = cmd.get("message", "OK")
|
msg = cmd.get("message", "OK")
|
||||||
|
|
||||||
if action == "position":
|
if action == "position":
|
||||||
|
|||||||
Reference in New Issue
Block a user