Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def generate_landing_page(title, header_font, body_font, primary_color, secondary_color, paragraphs, image_descriptions):
|
| 4 |
+
html_content = f"""
|
| 5 |
+
<!DOCTYPE html>
|
| 6 |
+
<html lang='en'>
|
| 7 |
+
<head>
|
| 8 |
+
<meta charset='UTF-8'>
|
| 9 |
+
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
| 10 |
+
<title>{title}</title>
|
| 11 |
+
<link href='https://fonts.googleapis.com/css2?family={header_font.replace(" ", "+")}&display=swap' rel='stylesheet'>
|
| 12 |
+
<link href='https://fonts.googleapis.com/css2?family={body_font.replace(" ", "+")}&display=swap' rel='stylesheet'>
|
| 13 |
+
<style>
|
| 14 |
+
body {{ font-family: '{body_font}', sans-serif; color: {secondary_color}; background-color: {primary_color}; margin: 0; padding: 20px; }}
|
| 15 |
+
h1 {{ font-family: '{header_font}', sans-serif; text-align: center; }}
|
| 16 |
+
.content {{ max-width: 800px; margin: auto; }}
|
| 17 |
+
.image-box {{ margin-top: 20px; padding: 10px; background: {secondary_color}; color: {primary_color}; border-radius: 10px; }}
|
| 18 |
+
</style>
|
| 19 |
+
</head>
|
| 20 |
+
<body>
|
| 21 |
+
<h1>{title}</h1>
|
| 22 |
+
<div class='content'>
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
for para in paragraphs.split(","):
|
| 26 |
+
html_content += f"<p>{para.strip()}</p>\n"
|
| 27 |
+
|
| 28 |
+
for desc in image_descriptions.split(","):
|
| 29 |
+
html_content += f"<div class='image-box'><strong>Image:</strong> {desc.strip()}</div>\n"
|
| 30 |
+
|
| 31 |
+
html_content += """
|
| 32 |
+
</div>
|
| 33 |
+
</body>
|
| 34 |
+
</html>
|
| 35 |
+
"""
|
| 36 |
+
|
| 37 |
+
return html_content
|
| 38 |
+
|
| 39 |
+
with gr.Blocks() as demo:
|
| 40 |
+
gr.Markdown("## Landing Page Generator")
|
| 41 |
+
|
| 42 |
+
with gr.Row():
|
| 43 |
+
title = gr.Textbox(label="Landing Page Title")
|
| 44 |
+
header_font = gr.Textbox(label="Header Font (Google Font)", value="Roboto Slab")
|
| 45 |
+
body_font = gr.Textbox(label="Body Font (Google Font)", value="Open Sans")
|
| 46 |
+
|
| 47 |
+
with gr.Row():
|
| 48 |
+
primary_color = gr.ColorPicker(label="Primary Color", value="#ffffff")
|
| 49 |
+
secondary_color = gr.ColorPicker(label="Secondary Color", value="#333333")
|
| 50 |
+
|
| 51 |
+
paragraphs = gr.Textbox(label="Enter 10 paragraphs (comma-separated)")
|
| 52 |
+
image_descriptions = gr.Textbox(label="Enter 10 image descriptions (comma-separated)")
|
| 53 |
+
|
| 54 |
+
generate_button = gr.Button("Generate Landing Page")
|
| 55 |
+
output_html = gr.Code(label="Generated HTML Code")
|
| 56 |
+
|
| 57 |
+
generate_button.click(
|
| 58 |
+
generate_landing_page,
|
| 59 |
+
inputs=[title, header_font, body_font, primary_color, secondary_color, paragraphs, image_descriptions],
|
| 60 |
+
outputs=output_html
|
| 61 |
+
)
|
| 62 |
+
|
| 63 |
+
demo.launch()
|