Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def combine_inputs(title, content):
|
| 4 |
+
# Create a simple HTML template with the inputs
|
| 5 |
+
html = f"""
|
| 6 |
+
<div style="font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px;">
|
| 7 |
+
<h1 style="color: #2c3e50;">{title}</h1>
|
| 8 |
+
<div style="background-color: #f7f9fc; padding: 15px; border-radius: 8px;">
|
| 9 |
+
<p style="line-height: 1.6;">{content}</p>
|
| 10 |
+
</div>
|
| 11 |
+
<footer style="margin-top: 20px; color: #7f8c8d; font-size: 0.9em;">
|
| 12 |
+
Generated with Gradio
|
| 13 |
+
</footer>
|
| 14 |
+
</div>
|
| 15 |
+
"""
|
| 16 |
+
return html
|
| 17 |
+
|
| 18 |
+
# Create the interface
|
| 19 |
+
with gr.Blocks() as demo:
|
| 20 |
+
gr.Markdown("# HTML Generator")
|
| 21 |
+
|
| 22 |
+
with gr.Row():
|
| 23 |
+
title_input = gr.Textbox(label="Title", placeholder="Enter your title here")
|
| 24 |
+
content_input = gr.Textbox(label="Content", placeholder="Enter your content here", lines=3)
|
| 25 |
+
|
| 26 |
+
generate_btn = gr.Button("Generate HTML")
|
| 27 |
+
output = gr.HTML(label="Generated HTML")
|
| 28 |
+
|
| 29 |
+
generate_btn.click(
|
| 30 |
+
fn=combine_inputs,
|
| 31 |
+
inputs=[title_input, content_input],
|
| 32 |
+
outputs=output
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
demo.launch()
|