added restapi
This commit is contained in:
+9
-1
@@ -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 ---
|
||||
|
||||
Reference in New Issue
Block a user