Spaces:
Sleeping
Sleeping
Commit ·
d48c2db
1
Parent(s): af49bdb
Add config download endpoint
Browse files- backend/api.py +8 -0
backend/api.py
CHANGED
|
@@ -103,6 +103,14 @@ async def send_config(request: Request):
|
|
| 103 |
|
| 104 |
pdf_path = UPLOADS_DIR / f"{pdf_id}.pdf"
|
| 105 |
return {"ok": True, "stored": str(out_path), "pdf_exists": pdf_path.exists()}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
@app.post("/api/notify-unknown")
|
| 107 |
async def notify_unknown(payload: Dict[str, Any]):
|
| 108 |
"""
|
|
|
|
| 103 |
|
| 104 |
pdf_path = UPLOADS_DIR / f"{pdf_id}.pdf"
|
| 105 |
return {"ok": True, "stored": str(out_path), "pdf_exists": pdf_path.exists()}
|
| 106 |
+
|
| 107 |
+
@app.get("/api/config/{pdf_id}/{template_id}")
|
| 108 |
+
def get_config(pdf_id: str, template_id: str):
|
| 109 |
+
path = CONFIGS_DIR / f"{pdf_id}__{template_id}.json"
|
| 110 |
+
if not path.exists():
|
| 111 |
+
raise HTTPException(status_code=404, detail="Config not found")
|
| 112 |
+
return FileResponse(path, media_type="application/json", filename=path.name)
|
| 113 |
+
|
| 114 |
@app.post("/api/notify-unknown")
|
| 115 |
async def notify_unknown(payload: Dict[str, Any]):
|
| 116 |
"""
|