Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
|
4 |
+
def greet(name, intensity):
|
5 |
+
"""
|
6 |
+
Simple greeting function that takes a name and intensity level
|
7 |
+
and returns a personalized greeting.
|
8 |
+
"""
|
9 |
+
greeting = f"Hello, {name}!"
|
10 |
+
if intensity > 50:
|
11 |
+
greeting = greeting.upper() + "!!" * (intensity // 20)
|
12 |
+
return greeting
|
13 |
+
|
14 |
+
|
15 |
+
# Create the Gradio interface
|
16 |
+
with gr.Blocks() as demo:
|
17 |
+
gr.Markdown("# Simple Greeting App")
|
18 |
+
|
19 |
+
with gr.Row():
|
20 |
+
with gr.Column():
|
21 |
+
name_input = gr.Textbox(
|
22 |
+
label="Your Name", placeholder="Enter your name here..."
|
23 |
+
)
|
24 |
+
intensity_slider = gr.Slider(
|
25 |
+
minimum=0, maximum=100, value=50, label="Enthusiasm Level", step=1
|
26 |
+
)
|
27 |
+
greet_btn = gr.Button("Generate Greeting")
|
28 |
+
|
29 |
+
with gr.Column():
|
30 |
+
output = gr.Textbox(label="Greeting Result")
|
31 |
+
|
32 |
+
greet_btn.click(fn=greet, inputs=[name_input, intensity_slider], outputs=output)
|
33 |
+
|
34 |
+
if __name__ == "__main__":
|
35 |
+
demo.launch()
|