Files
Tha.Les 32bdc38180 feat(settings): QR codes for network access (#238)
* feat(settings): QR codes for network access addresses

When server mode is on, show a scannable QR code for each local IP in
the desktop settings panel. Each QR encodes http://{ip}:{port}/mobile/
so the phone camera opens the mobile UI directly.

- Add segno (pure Python, no PIL) as a new dependency
- Add GET /api/qr?url=... endpoint that returns an SVG QR code
- Render one QR card per LAN address in the network settings section

* feat(settings): remove IP list, blur QR codes with tap-to-reveal

- Drop the yellow IP address chips; the QR label already shows the URL
- QR codes start blurred so a nearby camera app can't scan them
  immediately; tap any card to toggle the blur
- Add a hint line: "Blurred so your camera doesn't get too excited. Tap to reveal."

* fix(settings): increase gap between QR cards

* fix(settings): clip QR blur bleed with overflow hidden wrapper

* fix(settings): accent color border on QR cards

* fix(settings): thicker accent border on QR cards

* fix(settings): box-sizing border-box on QR wrap to stop corner clipping

* fix(settings): advanced pane scrolls so Done footer stays fixed at bottom
2026-06-29 19:19:59 +01:00

26 lines
657 B
Python

from __future__ import annotations
import io
import segno
from fastapi import APIRouter, HTTPException
from fastapi.responses import Response
router = APIRouter()
_MAX_LEN = 500
@router.get("/qr")
def get_qr(url: str) -> Response:
if not url or len(url) > _MAX_LEN:
raise HTTPException(status_code=422, detail="url required (max 500 chars)")
qr = segno.make_qr(url, error="m")
buf = io.BytesIO()
qr.save(buf, kind="svg", scale=5, border=2, dark="#1a1206", light="#ffffff")
return Response(
content=buf.getvalue(),
media_type="image/svg+xml",
headers={"Cache-Control": "public, max-age=3600"},
)