Vaibhav84 commited on
Commit
f296b1d
·
1 Parent(s): ca9140a
Files changed (1) hide show
  1. app.py +17 -21
app.py CHANGED
@@ -49,6 +49,12 @@ class SkillDetails(BaseModel):
49
  requiredSkills: str
50
  softSkills: str
51
  goodToHaveSkills: str
 
 
 
 
 
 
52
 
53
  class FileResponse(BaseModel):
54
  fileid: int
@@ -73,44 +79,34 @@ def parse_csv(df):
73
  parsed = json.loads(res)
74
  return parsed
75
 
76
- @app.post("/uploadJobDescriptionPDF/")
77
- def process_pdf_file(file: bytes = File(...)):
78
- # Save file locally for processing
79
- text =''
80
- reserve_pdf_on_memory = io.BytesIO(file)
81
- load_pdf = PyPDF2.PdfReader(reserve_pdf_on_memory)
82
- for page in load_pdf.pages:
83
- text += page.extract_text()
84
- print(text)
85
- # Process saved file
86
- return {"content": text}
87
 
88
- @app.post("/uploadJobDescriptionPDF_Fname/")
89
- def process_pdf_file1(file: bytes = File(...), FileName: str = str):
90
  # Save file locally for processing
91
  text =''
92
  print(text)
93
- if FileName.endswith("pdf"):
94
  reserve_pdf_on_memory = io.BytesIO(file)
95
  load_pdf = PyPDF2.PdfReader(reserve_pdf_on_memory)
96
  for page in load_pdf.pages:
97
  text += page.extract_text()
98
 
99
- elif FileName.endswith("doc") or FileName.endswith("docx"):
100
- text = docx2txt.process(file)
101
  text = text.read()
102
 
103
  else:
104
  text = file.decode('utf-8')
105
 
106
- returnID = UploadOpenFile.uploadFile(text,FileName,db_params)
107
  returnSkills = SkillExtractorDetails.SkillExtract(db_params,skill_extractor,returnID)
108
  details = returnSkills.split('@')
109
- #skill_data.requiredSkills = details[0]
110
- #skill_data.softSkills = details[1]
111
- #skill_data.goodToHaveSkills = details[1]
112
  # Process saved file
113
- return {"content": details}
114
  @app.get("/ProfileMatch")
115
  def ProfileMatchResults():
116
  dbQuery = "select * from profilematch"
 
49
  requiredSkills: str
50
  softSkills: str
51
  goodToHaveSkills: str
52
+
53
+ class SkillData(BaseModel):
54
+ filename: str
55
+ requiredSkills: str
56
+ softSkills: str
57
+ goodToHaveSkills: str
58
 
59
  class FileResponse(BaseModel):
60
  fileid: int
 
79
  parsed = json.loads(res)
80
  return parsed
81
 
82
+
 
 
 
 
 
 
 
 
 
 
83
 
84
+ @app.post("/UploadJobDescription/")
85
+ def UploadJobDescription(file: bytes = File(...), FileData: SkillData = SkillData):
86
  # Save file locally for processing
87
  text =''
88
  print(text)
89
+ if FileData.FileName.endswith("pdf"):
90
  reserve_pdf_on_memory = io.BytesIO(file)
91
  load_pdf = PyPDF2.PdfReader(reserve_pdf_on_memory)
92
  for page in load_pdf.pages:
93
  text += page.extract_text()
94
 
95
+ elif FileData.FileName.endswith("doc") or FileData.FileName.endswith("docx"):
96
+ text = docx2txt.process(io.BytesIO(file))
97
  text = text.read()
98
 
99
  else:
100
  text = file.decode('utf-8')
101
 
102
+ returnID = UploadOpenFile.uploadFile(text,FileData.FileName,db_params)
103
  returnSkills = SkillExtractorDetails.SkillExtract(db_params,skill_extractor,returnID)
104
  details = returnSkills.split('@')
105
+ FileData.requiredSkills = details[0]
106
+ FileData.softSkills = details[1]
107
+ FileData.goodToHaveSkills = details[1]
108
  # Process saved file
109
+ return {"content": FileData}
110
  @app.get("/ProfileMatch")
111
  def ProfileMatchResults():
112
  dbQuery = "select * from profilematch"