Spaces:
Sleeping
Sleeping
Ammar-Abdelhady-ai
commited on
Commit
·
54e31a8
1
Parent(s):
accfc4d
Add application file
Browse files
main.py
CHANGED
|
@@ -2,6 +2,7 @@ import threading
|
|
| 2 |
from functions import extract_text_from_pdf, get_most_similar_job
|
| 3 |
from fastapi import UploadFile, HTTPException, FastAPI
|
| 4 |
import pandas as pd
|
|
|
|
| 5 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
| 6 |
|
| 7 |
|
|
@@ -64,18 +65,21 @@ app = FastAPI(project_name="cv")
|
|
| 64 |
async def read_root():
|
| 65 |
return {"Hello": "World, Project name is : CV Description"}
|
| 66 |
|
|
|
|
| 67 |
@app.post("/prediction")
|
| 68 |
async def detect(cv: UploadFile, number_of_jobs: int):
|
| 69 |
-
|
| 70 |
if (type(number_of_jobs) != int) or (number_of_jobs < 1) or (number_of_jobs > df.shape[0]):
|
| 71 |
raise HTTPException(
|
| 72 |
-
status_code=415, detail
|
| 73 |
)
|
| 74 |
|
| 75 |
-
if cv.filename.split(".")[-1] not in ("pdf")
|
| 76 |
raise HTTPException(
|
| 77 |
-
status_code=415, detail="Please
|
| 78 |
)
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
|
| 81 |
|
|
|
|
| 2 |
from functions import extract_text_from_pdf, get_most_similar_job
|
| 3 |
from fastapi import UploadFile, HTTPException, FastAPI
|
| 4 |
import pandas as pd
|
| 5 |
+
from fastapi import UploadFile, HTTPException
|
| 6 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
| 7 |
|
| 8 |
|
|
|
|
| 65 |
async def read_root():
|
| 66 |
return {"Hello": "World, Project name is : CV Description"}
|
| 67 |
|
| 68 |
+
|
| 69 |
@app.post("/prediction")
|
| 70 |
async def detect(cv: UploadFile, number_of_jobs: int):
|
|
|
|
| 71 |
if (type(number_of_jobs) != int) or (number_of_jobs < 1) or (number_of_jobs > df.shape[0]):
|
| 72 |
raise HTTPException(
|
| 73 |
+
status_code=415, detail=f"Please enter the number of jobs as an integer from 1 to {int(df.shape[0]) - 1}."
|
| 74 |
)
|
| 75 |
|
| 76 |
+
if cv.filename.split(".")[-1] not in ("pdf"):
|
| 77 |
raise HTTPException(
|
| 78 |
+
status_code=415, detail="Please upload a PDF file."
|
| 79 |
)
|
| 80 |
+
|
| 81 |
+
# The rest of your code...
|
| 82 |
+
|
| 83 |
|
| 84 |
|
| 85 |
|