File size: 726 Bytes
aac350d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | """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"})
|