DreamStream-1 commited on
Commit
583146a
·
verified ·
1 Parent(s): 4690f7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -46,20 +46,22 @@ def analyze_documents(resume_text, job_description):
46
  response = requests.post(url, headers=headers, json=data)
47
  return response.json()
48
 
49
- def display_resume(file):
 
50
  file_type = file.name.split('.')[-1].lower()
 
51
  if file_type == 'pdf':
52
  reader = PdfReader(file)
53
  text = ""
54
  for page in reader.pages:
55
  text += page.extract_text()
56
- st.text_area("Parsed Resume Content", text, height=400)
57
  elif file_type == 'docx':
58
  doc = Document(file)
59
  text = ""
60
  for para in doc.paragraphs:
61
  text += para.text + "\n"
62
- st.text_area("Parsed Resume Content", text, height=400)
63
  else:
64
  st.error("Unsupported file type. Please upload a PDF or DOCX file.")
65
 
@@ -77,15 +79,15 @@ if page == "Resume Analyzer":
77
 
78
  if resumes:
79
  st.write("Uploaded Resumes:")
80
- for resume in resumes:
81
  st.write(f"📄 {resume.name}")
82
- display_resume(resume)
83
 
84
  if st.button("Analyze Resumes"):
85
  if job_description and resumes:
86
  if len(resumes) <= 10: # Limit to a maximum of 10 resumes
87
  with st.spinner("Analyzing..."):
88
- for resume in resumes:
89
  resume.seek(0) # Reset the file pointer
90
  file_type = resume.name.split('.')[-1].lower()
91
 
 
46
  response = requests.post(url, headers=headers, json=data)
47
  return response.json()
48
 
49
+ def display_resume(file, index):
50
+ """Display uploaded resume content with a unique key."""
51
  file_type = file.name.split('.')[-1].lower()
52
+ unique_key = f"{file.name}_{index}" # Ensure the key is unique by appending an index
53
  if file_type == 'pdf':
54
  reader = PdfReader(file)
55
  text = ""
56
  for page in reader.pages:
57
  text += page.extract_text()
58
+ st.text_area(f"Parsed Resume Content - {file.name}", text, height=400, key=unique_key)
59
  elif file_type == 'docx':
60
  doc = Document(file)
61
  text = ""
62
  for para in doc.paragraphs:
63
  text += para.text + "\n"
64
+ st.text_area(f"Parsed Resume Content - {file.name}", text, height=400, key=unique_key)
65
  else:
66
  st.error("Unsupported file type. Please upload a PDF or DOCX file.")
67
 
 
79
 
80
  if resumes:
81
  st.write("Uploaded Resumes:")
82
+ for index, resume in enumerate(resumes):
83
  st.write(f"📄 {resume.name}")
84
+ display_resume(resume, index) # Passing the index to ensure unique keys
85
 
86
  if st.button("Analyze Resumes"):
87
  if job_description and resumes:
88
  if len(resumes) <= 10: # Limit to a maximum of 10 resumes
89
  with st.spinner("Analyzing..."):
90
+ for index, resume in enumerate(resumes):
91
  resume.seek(0) # Reset the file pointer
92
  file_type = resume.name.split('.')[-1].lower()
93