Spaces:
Sleeping
Sleeping
Crs-Lionel
Claude Opus 4.8
Initial commit: FilezKit backend + frontend, dockerized for HF Spaces
82a25a8 Download backend/app/workers/pdf_to_html.py from tech-ties/filezkit-backend: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/spaces/tech-ties/filezkit-backend/resolve/main/backend/app/workers/pdf_to_html.py
- Command line
-
hf download hf://spaces/tech-ties/filezkit-backend/backend/app/workers/pdf_to_html.py
-
curl -L -o pdf_to_html.py https://huggingface.co/spaces/tech-ties/filezkit-backend/resolve/main/backend/app/workers/pdf_to_html.py
1.11 kB
| from pdfminer.high_level import extract_text_to_fp | |
| from pdfminer.layout import LAParams | |
| from app.core.celery_app import celery_app | |
| from app.db.session import SessionLocal | |
| from app.workers.conversion_helpers import ( | |
| complete_job, | |
| fail_job, | |
| outputs_dir, | |
| start_file_job | |
| ) | |
| def pdf_to_html_task(job_id: int): | |
| db = SessionLocal() | |
| job = None | |
| try: | |
| job, input_path = start_file_job(db, job_id) | |
| if not job: | |
| return | |
| output_path = ( | |
| outputs_dir() | |
| / | |
| f"pdf_to_html_{job_id}.html" | |
| ) | |
| with open(input_path, "rb") as input_file: | |
| with open(output_path, "w", encoding="utf-8") as output_file: | |
| extract_text_to_fp( | |
| input_file, | |
| output_file, | |
| laparams=LAParams(), | |
| output_type="html", | |
| codec=None | |
| ) | |
| complete_job(db, job, output_path) | |
| except Exception as e: | |
| fail_job(db, job, "PDF To HTML", job_id, e) | |
| finally: | |
| db.close() | |