Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
@@ -10,12 +10,17 @@ def process_resumes(job_description, uploaded_file):
|
|
10 |
if not job_description.strip():
|
11 |
return "Please provide a job description.", None
|
12 |
|
13 |
-
# Save uploaded file
|
14 |
filepath = os.path.join(UPLOAD_FOLDER, uploaded_file.name)
|
15 |
-
with open(filepath, "wb") as f:
|
16 |
-
f.write(uploaded_file.read())
|
17 |
|
18 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
if filepath.endswith(".txt"):
|
20 |
with open(filepath, "r", encoding="utf-8") as f:
|
21 |
text = f.read()
|
@@ -47,6 +52,7 @@ def process_resumes(job_description, uploaded_file):
|
|
47 |
return "", table_data
|
48 |
|
49 |
|
|
|
50 |
with gr.Blocks() as demo:
|
51 |
gr.Markdown("## Candidate Recommendation Engine")
|
52 |
with gr.Row():
|
|
|
10 |
if not job_description.strip():
|
11 |
return "Please provide a job description.", None
|
12 |
|
|
|
13 |
filepath = os.path.join(UPLOAD_FOLDER, uploaded_file.name)
|
|
|
|
|
14 |
|
15 |
+
# Fix here: uploaded_file might be a file-like object or just string content
|
16 |
+
if hasattr(uploaded_file, "read"): # file-like object (e.g., PDF)
|
17 |
+
with open(filepath, "wb") as f:
|
18 |
+
f.write(uploaded_file.read())
|
19 |
+
else: # string content (likely txt)
|
20 |
+
with open(filepath, "w", encoding="utf-8") as f:
|
21 |
+
f.write(uploaded_file)
|
22 |
+
|
23 |
+
# Read the saved resume content
|
24 |
if filepath.endswith(".txt"):
|
25 |
with open(filepath, "r", encoding="utf-8") as f:
|
26 |
text = f.read()
|
|
|
52 |
return "", table_data
|
53 |
|
54 |
|
55 |
+
|
56 |
with gr.Blocks() as demo:
|
57 |
gr.Markdown("## Candidate Recommendation Engine")
|
58 |
with gr.Row():
|