feat(provenance): /api/provenance image + post endpoints
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,7 @@ def all_blueprints() -> list[Blueprint]:
|
||||
from .gallery import gallery_bp
|
||||
from .import_admin import import_admin_bp
|
||||
from .ml_admin import ml_admin_bp
|
||||
from .provenance import provenance_bp
|
||||
from .settings import settings_bp
|
||||
from .showcase import showcase_bp
|
||||
from .suggestions import suggestions_bp
|
||||
@@ -27,6 +28,7 @@ def all_blueprints() -> list[Blueprint]:
|
||||
return [
|
||||
api_bp,
|
||||
gallery_bp,
|
||||
provenance_bp,
|
||||
tags_bp,
|
||||
artist_bp,
|
||||
showcase_bp,
|
||||
|
||||
@@ -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