Spaces:
Sleeping
Sleeping
Commit ·
e3b7e75
1
Parent(s): 9ea86b6
Make /api/send-config store config even if PDF missing
Browse files60 unmodified lines61626364656667686939 unmodified lines10911011111211311411511611711860 unmodified lines@app.get("/health")def health():return {"ok": True}@app.get("/api/pdf/{pdf_id}")def get_pdf(pdf_id: str):path = UPLOADS_DIR / f"{pdf_id}.pdf"39 unmodified linesraise HTTPException(status_code=400, detail="Missing config object")# PDF must exist in API uploads (worker uploads it first)pdf_path = UPLOADS_DIR / f"{pdf_id}.pdf"if not pdf_path.exists():raise HTTPException(status_code=404, detail="PDF not found for pdf_id")name_path = UPLOADS_DIR / f"{pdf_id}.name.txt"pdf_name = name_path.read_text(encoding="utf-8").strip() if name_path.exists() else f"{pdf_id}.pdf"60 unmodified lines6162636465666739 unmodified lines10710810911011111211311411511611711811960 unmodified lines@app.get("/health")def health():return {"ok": True, "stored": str(out_path), "pdf_attached": bool(pdf_exists)}@app.get("/api/pdf/{pdf_id}")def get_pdf(pdf_id: str):path = UPLOADS_DIR / f"{pdf_id}.pdf"39 unmodified linesraise HTTPException(status_code=400, detail="Missing config object")# PDF must exist in API uploads (worker uploads it first)# Always store config, even if PDF is missing in this containerCONFIGS_DIR.mkdir(parents=True, exist_ok=True)out_path = CONFIGS_DIR / f"{pdf_id}__{template_id}.json"out_path.write_text(json.dumps({"pdf_id": pdf_id, "template_id": template_id, "config": config}, indent=2), encoding="utf-8")pdf_path = UPLOADS_DIR / f"{pdf_id}.pdf"pdf_exists = pdf_path.exists()name_path = UPLOADS_DIR / f"{pdf_id}.name.txt"pdf_name = name_path.read_text(encoding="utf-8").strip() if name_path.exists() else f"{pdf_id}.pdf"
backend/api.py+7-6