Vaibhav84 commited on
Commit
8d08b4d
·
1 Parent(s): 5a698d2
Files changed (1) hide show
  1. app.py +22 -11
app.py CHANGED
@@ -51,7 +51,7 @@ class SkillDetails(BaseModel):
51
  goodToHaveSkills: str
52
 
53
  class SkillData(BaseModel):
54
- Filename: str
55
  requiredSkills: str
56
  softSkills: str
57
  goodToHaveSkills: str
@@ -81,32 +81,32 @@ def parse_csv(df):
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"
@@ -114,6 +114,17 @@ def ProfileMatchResults():
114
  df = pd.read_sql_query(dbQuery, conn)
115
  return parse_csv(df)
116
 
 
 
 
 
 
 
 
 
 
 
 
117
  @app.post("/ExtractSkills/")
118
  def ExtractSkills(skill_data: SkillDetails):
119
  returnSkills = SkillExtractorDetails.SkillExtract(db_params,skill_extractor,skill_data.skillid)
 
51
  goodToHaveSkills: str
52
 
53
  class SkillData(BaseModel):
54
+ filename: str
55
  requiredSkills: str
56
  softSkills: str
57
  goodToHaveSkills: str
 
81
 
82
 
83
 
84
+ @app.post("/uploadJobDescriptionPDF_Fname/")
85
+ def process_pdf_file1(file: bytes = File(...), FileName: str = str):
86
  # Save file locally for processing
87
  text =''
88
  print(text)
89
+ if 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 FileName.endswith("doc") or FileName.endswith("docx"):
96
+ text = docx2txt.process(file)
97
  text = text.read()
98
 
99
  else:
100
  text = file.decode('utf-8')
101
 
102
+ returnID = UploadOpenFile.uploadFile(text,FileName,db_params)
103
  returnSkills = SkillExtractorDetails.SkillExtract(db_params,skill_extractor,returnID)
104
  details = returnSkills.split('@')
105
+ #skill_data.requiredSkills = details[0]
106
+ #skill_data.softSkills = details[1]
107
+ #skill_data.goodToHaveSkills = details[1]
108
  # Process saved file
109
+ return {"content": details}
110
  @app.get("/ProfileMatch")
111
  def ProfileMatchResults():
112
  dbQuery = "select * from profilematch"
 
114
  df = pd.read_sql_query(dbQuery, conn)
115
  return parse_csv(df)
116
 
117
+ @app.post("/UploadFile/")
118
+ def UploadFileDetails(file_data: FileDetails):
119
+
120
+ returnID = UploadOpenFile.uploadFile(file_data.filecontents,file_data.filename,db_params)
121
+ file_data.filecontents = ""
122
+ file_data.fileid = str(returnID)
123
+ file_data.message = "File Uploaded Successfully!"
124
+
125
+ return file_data
126
+
127
+
128
  @app.post("/ExtractSkills/")
129
  def ExtractSkills(skill_data: SkillDetails):
130
  returnSkills = SkillExtractorDetails.SkillExtract(db_params,skill_extractor,skill_data.skillid)