sync: 鍚屾灞€鍩熺綉鏈€鏂颁唬鐮?(source master @ b69568e4)
This commit is contained in:
1 parent
4f7f07504a
commit
8bc8b0e082
1651 files changed
+278599
-11416
No files matched your search
@@ -0,0 +1,36 @@
|
||||
"""Public, signed image files for generated-HTML backgrounds."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from fastapi.responses import FileResponse
|
||||
|
||||
from deerflow.html_runtime.public_images import (
|
||||
image_media_type,
|
||||
resolve_html_image_path,
|
||||
verify_html_image_token,
|
||||
)
|
||||
|
||||
router = APIRouter(prefix="/api/public/html-images", tags=["html-images"])
|
||||
|
||||
_PUBLIC_HEADERS = {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
"Cross-Origin-Resource-Policy": "cross-origin",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
"Cache-Control": "public, max-age=86400",
|
||||
}
|
||||
|
||||
|
||||
@router.get("/{token}")
|
||||
async def get_html_image(token: str) -> FileResponse:
|
||||
"""Serve one raster image referenced by a generated HTML page."""
|
||||
try:
|
||||
thread_id, kind, filename = verify_html_image_token(token)
|
||||
path = resolve_html_image_path(thread_id, kind, filename)
|
||||
except (ValueError, FileNotFoundError):
|
||||
raise HTTPException(status_code=404, detail="HTML image not found") from None
|
||||
return FileResponse(
|
||||
path,
|
||||
media_type=image_media_type(filename),
|
||||
headers=_PUBLIC_HEADERS,
|
||||
)
|
||||
Reference in new issue
Block a user