Spaces:
Runtime error
Runtime error
LPX55
Refactor app.py to modularize tab functionality by introducing greeting_tab, calculator_tab, and sepia_tab functions for improved readability and maintainability
4478d67
import gradio as gr | |
from app import greet, download_text | |
def greeting_tab(): | |
gr.Markdown("## Greeting Generator") | |
with gr.Row(): | |
with gr.Column(): | |
name = gr.Textbox(label="Name", info="Enter your name", placeholder="e.g. Alex") | |
intensity = gr.Slider(1, 20, value=3, step=1, label="Intensity", info="How excited should the greeting be?") | |
with gr.Accordion("Advanced Options", open=False): | |
exclaim = gr.Checkbox(label="Shout (all caps)", info="Make the greeting all uppercase and add exclamations") | |
greet_btn = gr.Button("Greet") | |
with gr.Column(): | |
greet_output = gr.Textbox(label="Greeting", lines=2) | |
download_greet_btn = gr.DownloadButton(label="Download Greeting", value=download_text, inputs=greet_output) | |
gr.Examples( | |
[["Jill", 1, False], ["Sam", 3, True], ["Alex", 5, False]], | |
inputs=[name, intensity, exclaim], | |
outputs=greet_output, | |
fn=greet | |
) | |
greet_btn.click(greet, [name, intensity, exclaim], greet_output) |