Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
|
|
|
| 3 |
from recommender import rank_resumes, summarize_resume_flan, extract_applicant_name
|
| 4 |
from docx import Document
|
| 5 |
-
import pdfplumber
|
| 6 |
-
|
| 7 |
|
| 8 |
UPLOAD_FOLDER = "uploads"
|
| 9 |
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
|
|
@@ -22,7 +21,7 @@ def process_resumes(job_description, uploaded_files):
|
|
| 22 |
|
| 23 |
ext = filename.lower().split(".")[-1]
|
| 24 |
|
| 25 |
-
# Save uploaded file
|
| 26 |
file_path = os.path.join(UPLOAD_FOLDER, filename)
|
| 27 |
with open(file_path, "wb") as f:
|
| 28 |
content = uploaded_file.read() if hasattr(uploaded_file, "read") else uploaded_file
|
|
@@ -30,7 +29,7 @@ def process_resumes(job_description, uploaded_files):
|
|
| 30 |
content = content.encode("utf-8")
|
| 31 |
f.write(content)
|
| 32 |
|
| 33 |
-
# Read file content
|
| 34 |
if ext == "txt":
|
| 35 |
with open(file_path, "r", encoding="utf-8") as f:
|
| 36 |
text = f.read()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
+
import pdfplumber
|
| 4 |
from recommender import rank_resumes, summarize_resume_flan, extract_applicant_name
|
| 5 |
from docx import Document
|
|
|
|
|
|
|
| 6 |
|
| 7 |
UPLOAD_FOLDER = "uploads"
|
| 8 |
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
|
|
|
|
| 21 |
|
| 22 |
ext = filename.lower().split(".")[-1]
|
| 23 |
|
| 24 |
+
# Save the uploaded file locally first
|
| 25 |
file_path = os.path.join(UPLOAD_FOLDER, filename)
|
| 26 |
with open(file_path, "wb") as f:
|
| 27 |
content = uploaded_file.read() if hasattr(uploaded_file, "read") else uploaded_file
|
|
|
|
| 29 |
content = content.encode("utf-8")
|
| 30 |
f.write(content)
|
| 31 |
|
| 32 |
+
# Read file content based on extension
|
| 33 |
if ext == "txt":
|
| 34 |
with open(file_path, "r", encoding="utf-8") as f:
|
| 35 |
text = f.read()
|