ElonMuskTeslaMarketingDepartment commited on
Commit
c36820b
·
verified ·
1 Parent(s): 06a4b95

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import gradio as gr
2
  from io import BytesIO
3
- import base64
4
 
5
  # HTML template with placeholders like {title_one}, {subtitle_one}, etc.
6
  HTML_TEMPLATE = """<!DOCTYPE html>
@@ -257,8 +256,10 @@ def generate_html(
257
  title_seven=title_seven,
258
  btn_primary_seven=btn_primary_seven
259
  )
260
- # Return as bytes for File component
261
- return html.encode('utf-8'), html
 
 
262
 
263
  with gr.Blocks(title="Tesla Page Editor") as demo:
264
  gr.Markdown("# Tesla Page Text Editor\nEdit texts below to customize sections for visitor engagement. Preview scrolls like the original!")
@@ -309,7 +310,7 @@ with gr.Blocks(title="Tesla Page Editor") as demo:
309
 
310
  with gr.Column(scale=2):
311
  preview = gr.HTML(label="Live Preview")
312
- download = gr.File(label="Download Updated index.html", file_types=[".html"])
313
 
314
  generate_btn.click(
315
  generate_html,
 
1
  import gradio as gr
2
  from io import BytesIO
 
3
 
4
  # HTML template with placeholders like {title_one}, {subtitle_one}, etc.
5
  HTML_TEMPLATE = """<!DOCTYPE html>
 
256
  title_seven=title_seven,
257
  btn_primary_seven=btn_primary_seven
258
  )
259
+ # For download: create BytesIO and set name
260
+ html_bytes = BytesIO(html.encode('utf-8'))
261
+ html_bytes.name = 'index.html'
262
+ return html_bytes, html # BytesIO for File, str for preview
263
 
264
  with gr.Blocks(title="Tesla Page Editor") as demo:
265
  gr.Markdown("# Tesla Page Text Editor\nEdit texts below to customize sections for visitor engagement. Preview scrolls like the original!")
 
310
 
311
  with gr.Column(scale=2):
312
  preview = gr.HTML(label="Live Preview")
313
+ download = gr.File(label="Download Updated index.html")
314
 
315
  generate_btn.click(
316
  generate_html,