diff --git a/main.py b/main.py index bc80c6b..d2ceb58 100644 --- a/main.py +++ b/main.py @@ -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()