Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -183,16 +183,25 @@ class ResumeJobMatcher:
|
|
| 183 |
if not job_description.strip():
|
| 184 |
return "Please provide a job description.", "", "", ""
|
| 185 |
|
| 186 |
-
#
|
| 187 |
-
|
| 188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
|
|
|
|
| 190 |
if filename.endswith('.pdf'):
|
| 191 |
resume_text = self.extract_text_from_pdf(file_content)
|
| 192 |
elif filename.endswith('.docx'):
|
| 193 |
resume_text = self.extract_text_from_docx(file_content)
|
| 194 |
else:
|
| 195 |
-
return "Unsupported file format. Please upload PDF or DOCX files.", "", "", ""
|
| 196 |
|
| 197 |
if "Error reading" in resume_text:
|
| 198 |
return resume_text, "", "", ""
|
|
@@ -281,7 +290,7 @@ def create_interface():
|
|
| 281 |
resume_file = gr.File(
|
| 282 |
label="Upload Resume (PDF/DOCX)",
|
| 283 |
file_types=[".pdf", ".docx"],
|
| 284 |
-
type="
|
| 285 |
)
|
| 286 |
|
| 287 |
gr.HTML("<h3>π Job Description</h3>")
|
|
|
|
| 183 |
if not job_description.strip():
|
| 184 |
return "Please provide a job description.", "", "", ""
|
| 185 |
|
| 186 |
+
# Handle different ways Gradio might pass the file
|
| 187 |
+
if hasattr(resume_file, 'name'):
|
| 188 |
+
filename = resume_file.name.lower()
|
| 189 |
+
# Read the file content
|
| 190 |
+
with open(resume_file.name, 'rb') as f:
|
| 191 |
+
file_content = f.read()
|
| 192 |
+
else:
|
| 193 |
+
# If resume_file is already the file path (string)
|
| 194 |
+
filename = str(resume_file).lower()
|
| 195 |
+
with open(resume_file, 'rb') as f:
|
| 196 |
+
file_content = f.read()
|
| 197 |
|
| 198 |
+
# Determine file type and extract text
|
| 199 |
if filename.endswith('.pdf'):
|
| 200 |
resume_text = self.extract_text_from_pdf(file_content)
|
| 201 |
elif filename.endswith('.docx'):
|
| 202 |
resume_text = self.extract_text_from_docx(file_content)
|
| 203 |
else:
|
| 204 |
+
return f"Unsupported file format for file: {filename}. Please upload PDF or DOCX files.", "", "", ""
|
| 205 |
|
| 206 |
if "Error reading" in resume_text:
|
| 207 |
return resume_text, "", "", ""
|
|
|
|
| 290 |
resume_file = gr.File(
|
| 291 |
label="Upload Resume (PDF/DOCX)",
|
| 292 |
file_types=[".pdf", ".docx"],
|
| 293 |
+
type="filepath"
|
| 294 |
)
|
| 295 |
|
| 296 |
gr.HTML("<h3>π Job Description</h3>")
|