|
|
|
|
|
|
|
import gradio as gr |
|
|
|
|
|
theme = gr.themes.Soft( |
|
primary_hue=gr.themes.Color("blue"), |
|
secondary_hue=gr.themes.Color("cyan"), |
|
neutral_hue=gr.themes.Color("gray"), |
|
text_size=gr.themes.Size("md"), |
|
spacing_size=gr.themes.Size("md"), |
|
radius_size=gr.themes.Size("md"), |
|
font=["IBM Plex Sans", "ui-sans-serif", "system-ui", "sans-serif"], |
|
font_mono=["IBM Plex Mono", "ui-monospace", "Consolas", "monospace"], |
|
) |
|
|
|
|
|
def greet(name): |
|
return "Hello " + name + "!" |
|
|
|
|
|
with gr.Blocks(theme=theme) as demo: |
|
|
|
gr.Markdown("# Welcome to the Interactive Greeting App!") |
|
gr.Markdown("Enter your name below to get a personalized greeting.") |
|
|
|
|
|
name_input = gr.Textbox(label="Your Name", placeholder="Enter your name here") |
|
|
|
|
|
greet_button = gr.Button("Greet Me", variant="primary") |
|
|
|
|
|
greeting_output = gr.Textbox(label="Greeting") |
|
|
|
|
|
greet_button.click(fn=greet, inputs=name_input, outputs=greeting_output) |
|
|
|
|
|
gr.Markdown("## Feedback") |
|
feedback_input = gr.Textbox(label="Your Feedback", placeholder="Tell us what you think!") |
|
submit_feedback_button = gr.Button("Submit Feedback", variant="secondary") |
|
feedback_output = gr.Textbox(label="Thank You!") |
|
|
|
|
|
def submit_feedback(feedback): |
|
return "Thank you for your feedback: " + feedback |
|
|
|
submit_feedback_button.click(fn=submit_feedback, inputs=feedback_input, outputs=feedback_output) |
|
|
|
|
|
if __name__ == "__main__": |
|
demo.launch(show_error=True) |