)
conn.commit()
return cur.lastrowid
-
+
except sqlite3.IntegrityError as e:
conn.rollback()
return -1
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
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,
return JSONResponse(
status_code=status.HTTP_200_OK,
content={
- "total": len(items),
+ "total": len(items),
"items": items
},
)
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"
},
} catch {
throw new Error('Invalid JSON payload');
}
-
+
// Check JSON errors
if (!res.ok) {
const serverMsg = data?.detail?.message?.trim();
// 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' },
});
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' },
});