Spaces:
Running
Running
File size: 668 Bytes
f3bc981 d475e29 4ce8d70 d475e29 09f8d76 5edc6a5 09f8d76 4ce8d70 5edc6a5 4ce8d70 5edc6a5 09f8d76 4ce8d70 09f8d76 5edc6a5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import gradio as gr
import os
import base64
def generate_html(name, code):
try:
with open(f"{name}.html", "w") as f:
f.write(code)
return f"HTML file {name}.html generated successfully!", {"name": f"{name}.html", "data": base64.b64encode(open(f"{name}.html", "rb").read()).decode("utf-8")}
except Exception as e:
return f"Error generating HTML file: {str(e)}", None
demo = gr.Interface(
fn=generate_html,
inputs=[
gr.Textbox(label="File Name"),
gr.Code(label="HTML Code")
],
outputs=[gr.Text(label="Status"), gr.File(label="Download HTML File")],
title="HTML Generator"
)
demo.launch() |