Ammar-Abdelhady-ai commited on
Commit
c6f585d
·
1 Parent(s): 54e31a8

Add application file

Browse files
Files changed (1) hide show
  1. main.py +11 -2
main.py CHANGED
@@ -66,18 +66,27 @@ 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
 
 
66
  return {"Hello": "World, Project name is : CV Description"}
67
 
68
 
69
+ from fastapi import UploadFile, Form, HTTPException
70
+ from pydantic import BaseModel
71
+
72
+ class CVUpload(BaseModel):
73
+ cv: UploadFile
74
+
75
  @app.post("/prediction")
76
+ async def detect(cv_data: CVUpload, number_of_jobs: int):
77
  if (type(number_of_jobs) != int) or (number_of_jobs < 1) or (number_of_jobs > df.shape[0]):
78
  raise HTTPException(
79
  status_code=415, detail=f"Please enter the number of jobs as an integer from 1 to {int(df.shape[0]) - 1}."
80
  )
81
 
82
+ if cv_data.cv.filename.split(".")[-1] not in ("pdf"):
83
  raise HTTPException(
84
  status_code=415, detail="Please upload a PDF file."
85
  )
86
 
87
+ cv = cv_data.cv
88
+ # The rest of your code...
89
+
90
  # The rest of your code...
91
 
92