Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -143,32 +143,33 @@ def upload_file(filepath):
|
|
| 143 |
clean_html_output = html_content.replace("```html", '').replace("```", '').strip()
|
| 144 |
|
| 145 |
# Debugging print to check the HTML content
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
# Prepare an iframe to embed the HTML content
|
| 149 |
-
iframe_html = f"<iframe srcdoc='{clean_html_output}' style='width:100%; height:600px; border:none;overflow-y:scroll;'></iframe>"
|
| 150 |
-
|
| 151 |
-
# Debugging print to check the iframe HTML
|
| 152 |
-
# print("Iframe HTML:", iframe_html)
|
| 153 |
|
| 154 |
# Save the cleaned HTML content to a file (if you still want this feature)
|
| 155 |
file_path = save_html_to_file(clean_html_output)
|
| 156 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
return iframe_html, gr.UploadButton(visible=False), gr.DownloadButton(label=f"Download Code", value=file_path, visible=True)
|
| 158 |
|
| 159 |
def download_file():
|
| 160 |
return [gr.UploadButton(label=f"Regenerate", visible=True), gr.DownloadButton(visible=False)]
|
| 161 |
|
| 162 |
|
|
|
|
| 163 |
with gr.Blocks() as demo:
|
| 164 |
gr.Markdown("<center><h1> CV-2-Portfolio Site Generator</center></h1>")
|
| 165 |
-
gr.Markdown("<center><h2>Upload your CV in PDF or DOCX format for analysis and portfolio webpage generation.</center></
|
| 166 |
|
| 167 |
u = gr.UploadButton("Upload CV (.pdf or .docx)", file_count="single")
|
| 168 |
d = gr.DownloadButton("Download Portfolio", visible=False)
|
| 169 |
|
| 170 |
-
# HTML
|
| 171 |
-
output_preview = gr.HTML(
|
|
|
|
|
|
|
| 172 |
|
| 173 |
# Connect the upload button to the upload_file function and update the output preview
|
| 174 |
u.upload(upload_file, u, [output_preview, u, d])
|
|
@@ -176,4 +177,4 @@ with gr.Blocks() as demo:
|
|
| 176 |
# Handle download button click
|
| 177 |
d.click(download_file, None, [u, d])
|
| 178 |
|
| 179 |
-
demo.launch()
|
|
|
|
| 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>")
|
| 164 |
+
gr.Markdown("<center><h2>Upload your CV in PDF or DOCX format for analysis and portfolio webpage generation.</center></h2>")
|
| 165 |
|
| 166 |
u = gr.UploadButton("Upload CV (.pdf or .docx)", file_count="single")
|
| 167 |
d = gr.DownloadButton("Download Portfolio", visible=False)
|
| 168 |
|
| 169 |
+
# Use gr.HTML with larger iframe size to display the full preview
|
| 170 |
+
output_preview = gr.HTML(
|
| 171 |
+
value="<div style='width:100%; height:1000px; border:1px solid #ccc; text-align:center;'>Upload a file to preview the generated portfolio</div>"
|
| 172 |
+
)
|
| 173 |
|
| 174 |
# Connect the upload button to the upload_file function and update the output preview
|
| 175 |
u.upload(upload_file, u, [output_preview, u, d])
|
|
|
|
| 177 |
# Handle download button click
|
| 178 |
d.click(download_file, None, [u, d])
|
| 179 |
|
| 180 |
+
demo.launch(debug=True)
|