Spaces:
Configuration error
Configuration error
Download app/pdf_handler.py from Dewasheesh/HelpDevelopersNew: direct link, hf CLI and curl.
- Browser
- Download file 405 Bytes
-
https://huggingface.co/spaces/Dewasheesh/HelpDevelopersNew/resolve/main/app/pdf_handler.py
- Command line
-
hf download hf://spaces/Dewasheesh/HelpDevelopersNew/app/pdf_handler.py
-
curl -L -o pdf_handler.py https://huggingface.co/spaces/Dewasheesh/HelpDevelopersNew/resolve/main/app/pdf_handler.py
405 Bytes
| import os | |
| from fastapi import UploadFile | |
| from app.vector_store import store_pdf | |
| UPLOAD_DIR = "data/uploaded_pdfs" | |
| def process_pdf(file: UploadFile): | |
| os.makedirs(UPLOAD_DIR, exist_ok=True) | |
| filepath = os.path.join(UPLOAD_DIR, file.filename) | |
| with open(filepath, "wb") as f: | |
| f.write(file.file.read()) | |
| store_pdf(filepath) | |
| return {"status": "uploaded", "filename": file.filename} | |