File size: 778 Bytes
9c80a11
 
 
 
 
 
 
 
 
 
94795b0
 
 
9c80a11
94795b0
 
 
c1cf179
94795b0
9c80a11
94795b0
9b63141
94795b0
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import gradio as gr

def generate_html():
    return "<p>This is a sample HTML content.</p>"

def download_html(content):
    with open("content.html", "w") as file:
        file.write(content)
    return "content.html"

with gr.Blocks() as demo:
    html_component = gr.HTML(generate_html)
    download_button = gr.DownloadButton(label="Download HTML")

    download_button.click(
        fn=download_html,
        inputs=html_component,
        outputs=download_button,
    )

demo.launch()

# download_button = gr.DownloadButton(label="Download HTML", inputs=html_component, value=download_html)
# interface = gr.Interface(fn=generate_html, 
#                          inputs=None, 
#                          outputs=[html_component, download_button])
#
#interface.launch()