File size: 1,457 Bytes
536d156
 
 
 
b4b6f00
536d156
 
b4b6f00
cef4393
536d156
 
 
4fb7a0a
b4b6f00
 
 
 
 
 
 
 
 
 
 
 
 
4fb7a0a
536d156
 
 
 
d4efc9c
536d156
 
c1da06e
536d156
 
c1da06e
536d156
 
d4efc9c
b4b6f00
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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=["*"],)

@app.get("/health")
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)

@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"}

    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