added restapi

This commit is contained in:
2026-11-02 16:46:20 +03:00
parent 9d74d06ce3
commit 588c2e0135
74 changed files with 7253 additions and 129 deletions
+9 -1
View File
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
"""Core configuration REST API (buttons, layout, background, feedback,
settings, icons) for the ButtonTask web configurator."""
import secrets
import uuid
from pathlib import Path
@@ -331,9 +332,16 @@ def api_set_settings():
if val < 1024 or val > 65535:
abort(400, "web port must be 1024–65535")
st[k] = val
rotated = None
if data.get("rotateApiKey"):
rotated = secrets.token_urlsafe(24)
st["apiKey"] = rotated
cfg["settings"] = st
save_config(cfg)
return jsonify({"ok": True})
body = {"ok": True}
if rotated is not None:
body["apiKey"] = rotated
return jsonify(body)
# --- icons ---