Spaces:
Runtime error
Runtime error
| from fastapi import FastAPI, UploadFile, File, Form | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from ats_core import extract_pdf_text, ats_score | |
| from role_templates import ROLE_TEMPLATES | |
| from ai_suggestions import generate_suggestions | |
| app = FastAPI() | |
| app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"],) | |
| def health(): | |
| return {"status": "ok"} | |
| # @app.post("/ats-score") | |
| # async def score( resume: UploadFile = File(...), role: str = Form(...), job_description: str = Form("") ): | |
| # pdf_bytes = await resume.read() | |
| # resume_text = extract_pdf_text(pdf_bytes) | |
| # role = role.lower().strip() | |
| # jd = job_description if job_description.strip() else ROLE_TEMPLATES.get(role, "") | |
| # if not jd: | |
| # return {"error": "Invalid role"} | |
| # return ats_score(resume_text, jd, role) | |
| async def score( | |
| resume: UploadFile = File(...), | |
| role: str = Form(...), | |
| job_description: str = Form("") | |
| ): | |
| pdf_bytes = await resume.read() | |
| resume_text = extract_pdf_text(pdf_bytes) | |
| role = role.lower().strip() | |
| jd = job_description if job_description.strip() else ROLE_TEMPLATES.get(role, "") | |
| if not jd: | |
| return {"error": "Invalid role"} | |
| ats_result = ats_score(resume_text, jd, role) | |
| ai_text = generate_suggestions(resume_text, jd, ats_result) | |
| ats_result["ai_suggestions"] = ai_text | |
| return ats_result |