revert: pdf gen

This commit is contained in:
Timothy J. Baek
2024-10-13 00:05:28 -07:00
parent 5dc05eac67
commit 112cbdccbb
14 changed files with 249 additions and 163 deletions

View File

@@ -56,8 +56,17 @@ class ChatForm(BaseModel):
async def download_chat_as_pdf(
form_data: ChatTitleMessagesForm,
):
response = PDFGenerator(form_data).generate_chat_pdf()
return response
try:
pdf_bytes = PDFGenerator(form_data).generate_chat_pdf()
return Response(
content=pdf_bytes,
media_type="application/pdf",
headers={"Content-Disposition": "attachment;filename=chat.pdf"},
)
except Exception as e:
print(e)
raise HTTPException(status_code=400, detail=str(e))
@router.get("/db/download")