Add GET /preview endpoint for HTML img tag use

POST /preview requires a JSON body so cannot be used in <img src>.
The new GET /preview?url=... delegates to the same handler and shares
all caching and authentication behaviour.
This commit is contained in:
Bruno Postle 2026-04-16 00:43:17 +01:00
parent 778f0004e7
commit 502e497d92

View file

@ -184,9 +184,19 @@ class PreviewRequest(BaseModel):
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Endpoint # Endpoints
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@app.get("/preview")
def preview_get(url: str) -> Response:
"""GET variant of POST /preview for use in HTML ``<img src>`` tags.
The ``url`` query parameter is the ifc:// URL to render. All caching
and authentication behaviour is identical to the POST endpoint.
"""
return preview(PreviewRequest(url=url))
@app.post("/preview") @app.post("/preview")
def preview(request: PreviewRequest) -> Response: def preview(request: PreviewRequest) -> Response:
"""Render an ifc:// URL to a PNG image. """Render an ifc:// URL to a PNG image.