feat(provenance): /api/provenance image + post endpoints
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
"""Provenance API: image -> posts, post -> header payload.
|
||||
|
||||
Separate from the gallery/tag APIs by design (provenance is its own
|
||||
system). Read-only.
|
||||
"""
|
||||
|
||||
from quart import Blueprint, jsonify
|
||||
|
||||
from ..extensions import get_session
|
||||
from ..services.provenance_service import ProvenanceService
|
||||
|
||||
provenance_bp = Blueprint("provenance", __name__,
|
||||
url_prefix="/api/provenance")
|
||||
|
||||
|
||||
@provenance_bp.route("/image/<int:image_id>", methods=["GET"])
|
||||
async def image_provenance(image_id: int):
|
||||
async with get_session() as session:
|
||||
svc = ProvenanceService(session)
|
||||
payload = await svc.for_image(image_id)
|
||||
if payload is None:
|
||||
return jsonify({"error": "not found"}), 404
|
||||
return jsonify(payload)
|
||||
|
||||
|
||||
@provenance_bp.route("/post/<int:post_id>", methods=["GET"])
|
||||
async def post_provenance(post_id: int):
|
||||
async with get_session() as session:
|
||||
svc = ProvenanceService(session)
|
||||
payload = await svc.for_post(post_id)
|
||||
if payload is None:
|
||||
return jsonify({"error": "not found"}), 404
|
||||
return jsonify(payload)
|
||||
Reference in New Issue
Block a user