feat(fc2c-i): showcase random-sample service and endpoint

This commit is contained in:
2026-05-15 15:49:25 -04:00
parent a638c469e0
commit a74b313596
5 changed files with 145 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
"""Showcase API: scalable random sample of images."""
from quart import Blueprint, jsonify, request
from ..extensions import get_session
from ..services.showcase_service import ShowcaseService
showcase_bp = Blueprint("showcase", __name__, url_prefix="/api/showcase")
@showcase_bp.route("", methods=["GET"])
async def random_showcase():
try:
limit = int(request.args.get("limit", "60"))
except ValueError:
return jsonify({"error": "limit must be an integer"}), 400
async with get_session() as session:
svc = ShowcaseService(session)
try:
images = await svc.random_sample(limit=limit)
except ValueError as exc:
return jsonify({"error": str(exc)}), 400
return jsonify({"images": images})