MCPcopy Create free account
hub / github.com/stemdeckapp/stemdeck / update_settings

Function update_settings

app/main.py:242–262  ·  view source on GitHub ↗

Update runtime settings. Reachable from the host machine always; from a LAN device only while network access is currently on (the gate below), so a phone can't change settings once the owner turned access off.

(request: Request)

Source from the content-addressed store, hash-verified

240
241@app.post("/api/settings", tags=["settings"])
242async def update_settings(request: Request) -> dict[str, object]:
243 """Update runtime settings. Reachable from the host machine always; from a
244 LAN device only while network access is currently on (the gate below), so a
245 phone can't change settings once the owner turned access off."""
246 try:
247 body = await request.json()
248 except Exception:
249 body = {}
250 if "allow_network" in body:
251 set_allow_network(bool(body["allow_network"]))
252 for key, setter in (
253 ("max_duration_sec", set_max_duration_sec),
254 ("video_max_height", set_video_max_height),
255 ("port", set_port),
256 ):
257 if key in body:
258 try:
259 setter(int(body[key]))
260 except (TypeError, ValueError):
261 raise HTTPException(status_code=422, detail=f"{key} must be an integer") from None
262 return _settings_payload()
263
264
265# Content-Security-Policy. Defense-in-depth so an injected string in the webview

Callers

nothing calls this directly

Calls 2

set_allow_networkFunction · 0.90
_settings_payloadFunction · 0.85

Tested by

no test coverage detected