saadlahori commited on
Commit
bc86d65
Β·
verified Β·
1 Parent(s): e42ab72

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -4
app.py CHANGED
@@ -1,7 +1,31 @@
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
+ # 🧠 Function to personalize the greeting
4
+ def greet(name, style, excitement_level):
5
+ base_greeting = {
6
+ "Friendly": "Hello",
7
+ "Formal": "Greetings",
8
+ "Casual": "Hey"
9
+ }[style]
10
 
11
+ return f"{base_greeting} {name}{'!' * excitement_level}"
12
+
13
+ # 🎨 Custom theme (dark and sleek)
14
+ theme = gr.themes.Soft(primary_hue="teal", secondary_hue="blue")
15
+
16
+ # 🧱 Create a modern layout with Blocks
17
+ with gr.Blocks(theme=theme, title="Greeting Generator") as demo:
18
+ gr.Markdown("## πŸ‘‹ Personalized Greeting App\nFill the form below and get a custom greeting!")
19
+
20
+ with gr.Row():
21
+ name = gr.Textbox(label="Your Name", placeholder="Enter your name here", lines=1)
22
+ style = gr.Dropdown(choices=["Friendly", "Formal", "Casual"], value="Friendly", label="Greeting Style")
23
+ excitement = gr.Slider(minimum=1, maximum=5, step=1, value=2, label="Excitement Level (Number of !)")
24
+
25
+ greet_btn = gr.Button("Generate Greeting πŸŽ‰")
26
+ output = gr.Textbox(label="Your Greeting", interactive=False)
27
+
28
+ greet_btn.click(fn=greet, inputs=[name, style, excitement], outputs=output)
29
+
30
+ # πŸš€ Launch the app in browser
31
+ demo.launch(inbrowser=True)