From: Giorgio Ravera Date: Fri, 6 Feb 2026 22:49:56 +0000 (+0100) Subject: fixed extra-spaces X-Git-Url: http://git.giorgioravera.it/?a=commitdiff_plain;h=2959a07dfd4efdba5269a5c4f6c51be0e5e50b09;p=network-manager.git fixed extra-spaces --- diff --git a/backend/db/hosts.py b/backend/db/hosts.py index 4901ccd..3287f27 100644 --- a/backend/db/hosts.py +++ b/backend/db/hosts.py @@ -114,7 +114,7 @@ def add_host(data: dict): ) conn.commit() return cur.lastrowid - + except sqlite3.IntegrityError as e: conn.rollback() return -1 diff --git a/backend/main.py b/backend/main.py index b4ba470..4984ad0 100644 --- a/backend/main.py +++ b/backend/main.py @@ -5,6 +5,7 @@ from contextlib import asynccontextmanager from fastapi import FastAPI, Request, status from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import FileResponse, RedirectResponse, JSONResponse, Response +from starlette.middleware.base import BaseHTTPMiddleware import logging import os # Import Routers @@ -116,6 +117,8 @@ app.include_router(dhcp_router) cors_origins = [ f"http://localhost:{settings.HTTP_PORT}", f"http://127.0.0.1:{settings.HTTP_PORT}", + # aggiungi qui host reali quando servi da hostname: + # "http://miohost:8000", "https://dominio.tld" ] app.add_middleware( CORSMiddleware, diff --git a/backend/routes/dhcp.py b/backend/routes/dhcp.py index 9ad16fe..14158bf 100644 --- a/backend/routes/dhcp.py +++ b/backend/routes/dhcp.py @@ -177,7 +177,7 @@ def api_dhcp_leases(request: Request): return JSONResponse( status_code=status.HTTP_200_OK, content={ - "total": len(items), + "total": len(items), "items": items }, ) diff --git a/backend/routes/login.py b/backend/routes/login.py index 6addb18..42ff197 100644 --- a/backend/routes/login.py +++ b/backend/routes/login.py @@ -24,7 +24,7 @@ def check_rate_limit(ip: str): if len(attempts) >= settings.LOGIN_MAX_ATTEMPTS: raise HTTPException( - status_code=status.HTTP_409_CONFLICT, + status_code=status.HTTP_409_CONFLICT, detail={ "error": "Too many login attempts" }, diff --git a/frontend/js/hosts.js b/frontend/js/hosts.js index 0964eb1..01fe81c 100644 --- a/frontend/js/hosts.js +++ b/frontend/js/hosts.js @@ -352,7 +352,7 @@ async function saveHost(hostData) { } catch { throw new Error('Invalid JSON payload'); } - + // Check JSON errors if (!res.ok) { const serverMsg = data?.detail?.message?.trim(); @@ -483,7 +483,7 @@ async function handleDeleteHost(e, el) { // Execute delete try { // Fetch data - const res = await fetch(`/api/hosts/${id}`, { + const res = await fetch(`/api/hosts/${id}`, { method: 'DELETE', headers: { 'Accept': 'application/json' }, }); @@ -588,7 +588,7 @@ async function handleReloadDNS() { async function handleReloadDHCP() { try { // Fetch data - const res = await fetch(`/api/dhcp/reload`, { + const res = await fetch(`/api/dhcp/reload`, { method: 'POST', headers: { 'Accept': 'application/json' }, });