Spaces:
Runtime error
Runtime error
Download api/routes.py from utkarsh134/FastAPI-Experience-Extractor: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/utkarsh134/FastAPI-Experience-Extractor/resolve/main/api/routes.py
- Command line
-
hf download hf://spaces/utkarsh134/FastAPI-Experience-Extractor/api/routes.py
-
curl -L -o routes.py https://huggingface.co/spaces/utkarsh134/FastAPI-Experience-Extractor/resolve/main/api/routes.py
1.03 kB
| from fastapi import APIRouter, File, UploadFile, Form, HTTPException | |
| import os | |
| from api.models import ResumeAnalysisResponse | |
| from services.resume_service import analyze_resume_document | |
| router = APIRouter() | |
| async def analyze_resume( | |
| resume_file: UploadFile = File(...), | |
| job_role: str = Form(...) | |
| ): | |
| _, file_extension = os.path.splitext(resume_file.filename) | |
| file_extension = file_extension.lower() | |
| allowed_extensions = ['.pdf', '.docx'] | |
| if file_extension not in allowed_extensions: | |
| raise HTTPException( | |
| status_code=400, | |
| detail=f"Only PDF and DOCX files are supported. Got: {file_extension}" | |
| ) | |
| try: | |
| file_bytes = await resume_file.read() | |
| result = analyze_resume_document(file_bytes, job_role, file_extension) | |
| return result | |
| except Exception as e: | |
| raise HTTPException(status_code=500, detail=f"Error processing resume: {str(e)}") |