muhammadsalmanalfaridzi commited on
Commit
67ff76d
Β·
verified Β·
1 Parent(s): ef396f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -98,6 +98,7 @@ def process_resume(file, jd_string):
98
 
99
  # Save the original resume in Markdown format
100
  original_file_path = "resumes/original_resume.md"
 
101
  with open(original_file_path, "w", encoding="utf-8") as f:
102
  f.write(original_text)
103
 
@@ -120,12 +121,16 @@ def process_resume(file, jd_string):
120
  return f"Error processing file: {str(e)}", "", None, None, ""
121
 
122
  def export_resume(new_resume):
 
 
 
123
  try:
124
  # Save optimized Markdown as PDF
125
  output_pdf_file = "resumes/resume_new.pdf"
126
- html_content = new_resume
 
127
  HTML(string=html_content).write_pdf(output_pdf_file, stylesheets=['resumes/style.css'])
128
- return f"Successfully exported resume to {output_pdf_file} πŸŽ‰"
129
  except Exception as e:
130
  return f"Failed to export resume: {str(e)} πŸ’”"
131
 
@@ -150,13 +155,13 @@ with gr.Blocks() as app:
150
  download_after = gr.File(label="Download Optimized Resume")
151
 
152
  export_button = gr.Button("Export Optimized Resume as PDF πŸš€")
153
- export_result = gr.Markdown(label="Export Result")
154
 
155
  # Bindings
156
  run_button.click(
157
- process_resume,
158
- inputs=[resume_input, jd_input],
159
- outputs=[before_md, after_md, download_before, download_after, output_suggestions]
160
  )
161
  export_button.click(export_resume, inputs=[after_md], outputs=[export_result])
162
 
 
98
 
99
  # Save the original resume in Markdown format
100
  original_file_path = "resumes/original_resume.md"
101
+ os.makedirs("resumes", exist_ok=True) # Ensure the directory exists
102
  with open(original_file_path, "w", encoding="utf-8") as f:
103
  f.write(original_text)
104
 
 
121
  return f"Error processing file: {str(e)}", "", None, None, ""
122
 
123
  def export_resume(new_resume):
124
+ """
125
+ Export the optimized resume as a PDF file.
126
+ """
127
  try:
128
  # Save optimized Markdown as PDF
129
  output_pdf_file = "resumes/resume_new.pdf"
130
+ os.makedirs("resumes", exist_ok=True) # Ensure the directory exists
131
+ html_content = f"<html><body>{new_resume}</body></html>" # Simple HTML wrapper
132
  HTML(string=html_content).write_pdf(output_pdf_file, stylesheets=['resumes/style.css'])
133
+ return output_pdf_file # Return the file path for download
134
  except Exception as e:
135
  return f"Failed to export resume: {str(e)} πŸ’”"
136
 
 
155
  download_after = gr.File(label="Download Optimized Resume")
156
 
157
  export_button = gr.Button("Export Optimized Resume as PDF πŸš€")
158
+ export_result = gr.File(label="Download PDF")
159
 
160
  # Bindings
161
  run_button.click(
162
+ process_resume,
163
+ inputs=[resume_input, jd_input],
164
+ outputs=[before_md, after_md, download_before, download_after, output_suggestions]
165
  )
166
  export_button.click(export_resume, inputs=[after_md], outputs=[export_result])
167