main.py aktualisiert

This commit is contained in:
2026-03-06 22:13:16 +00:00
parent 9168a349f2
commit 2d3321aa32

21
main.py
View File

@@ -230,6 +230,27 @@ async def get_node(node_id: int):
conn.close()
return dict(node) if node else {}
@app.put("/api/node/{node_id}")
async def api_update_node(node_id: int, request: Request):
data = await request.json()
name = data.get("name")
ip = data.get("ip")
if not name or not ip:
return {"status": "error", "message": "Name und IP sind erforderlich"}, 400
conn = get_db()
try:
# Update in der Datenbank
conn.execute('UPDATE nodes SET name=?, ip=? WHERE id=?', (name, ip, node_id))
conn.commit()
return {"status": "success"}
except Exception as e:
print(f"Fehler beim Update der Node: {e}")
return {"status": "error", "message": str(e)}, 500
finally:
conn.close()
@app.post("/add_node")
async def add_node(background_tasks: BackgroundTasks, name: str = Form(...), ip: str = Form(...), user: str = Form(...), password: str = Form(...)):
conn = get_db()