Sobit commited on
Commit
0986a31
·
verified ·
1 Parent(s): f9a28d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -135,29 +135,31 @@ def save_html_to_file(html_content):
135
  return output_file_path
136
 
137
 
 
 
138
  def upload_file(filepath):
139
  name = Path(filepath).name
140
  html_content = process_cv(filepath) # Get HTML content from the CV
141
 
142
- # Clean the HTML content (but keep this simple to start with)
143
  clean_html_output = html_content.replace("```html", '').replace("```", '').strip()
 
144
 
145
- # Debugging print to check the HTML content
146
- print("HTML content:", clean_html_output)
147
 
148
  # Save the cleaned HTML content to a file (if you still want this feature)
149
  file_path = save_html_to_file(clean_html_output)
150
 
151
  # Return a full HTML string with embedded iframe for preview
152
  iframe_html = f"""
153
- <iframe srcdoc="{clean_html_output}" style="width:100%; height:1000px; border:none; overflow:auto;"></iframe>
154
  """
155
  return iframe_html, gr.UploadButton(visible=False), gr.DownloadButton(label=f"Download Code", value=file_path, visible=True)
156
-
157
  def download_file():
158
  return [gr.UploadButton(label=f"Regenerate", visible=True), gr.DownloadButton(visible=False)]
159
 
160
-
161
  # Gradio App
162
  with gr.Blocks() as demo:
163
  gr.Markdown("<center><h1> CV-2-Portfolio Site Generator</center></h1>")
 
135
  return output_file_path
136
 
137
 
138
+ import html
139
+
140
  def upload_file(filepath):
141
  name = Path(filepath).name
142
  html_content = process_cv(filepath) # Get HTML content from the CV
143
 
144
+ # Clean the HTML content and escape it for proper iframe embedding
145
  clean_html_output = html_content.replace("```html", '').replace("```", '').strip()
146
+ escaped_html_content = html.escape(clean_html_output) # Escape HTML content
147
 
148
+ # Debugging print to check the escaped HTML content
149
+ #print("Escaped HTML content:", escaped_html_content)
150
 
151
  # Save the cleaned HTML content to a file (if you still want this feature)
152
  file_path = save_html_to_file(clean_html_output)
153
 
154
  # Return a full HTML string with embedded iframe for preview
155
  iframe_html = f"""
156
+ <iframe srcdoc="{escaped_html_content}" style="width:100%; height:1000px; border:none; overflow:auto;"></iframe>
157
  """
158
  return iframe_html, gr.UploadButton(visible=False), gr.DownloadButton(label=f"Download Code", value=file_path, visible=True)
159
+
160
  def download_file():
161
  return [gr.UploadButton(label=f"Regenerate", visible=True), gr.DownloadButton(visible=False)]
162
 
 
163
  # Gradio App
164
  with gr.Blocks() as demo:
165
  gr.Markdown("<center><h1> CV-2-Portfolio Site Generator</center></h1>")