"""Export routes — download job results as JSON.""" from __future__ import annotations from fastapi import APIRouter, Depends, HTTPException from fastapi.responses import PlainTextResponse from api.deps import get_export_service from services.export_service import ExportService router = APIRouter() @router.get("/{job_id}") async def export_job(job_id: str, svc: ExportService = Depends(get_export_service)): data = svc.export_job_json_str(job_id) if data is None: raise HTTPException(status_code=404, detail="Job not found") return PlainTextResponse(content=data, media_type="application/json", headers={"Content-Disposition": f"attachment; filename={job_id}.json"})