Spaces:
Paused
Paused
naming
Browse files
app.py
CHANGED
@@ -2,7 +2,11 @@ import gradio as gr
|
|
2 |
|
3 |
|
4 |
def greet(name: str) -> str:
|
5 |
-
|
|
|
|
|
|
|
|
|
6 |
|
7 |
|
8 |
with gr.Blocks() as demo:
|
@@ -11,11 +15,35 @@ with gr.Blocks() as demo:
|
|
11 |
gr.Markdown("""<p align="center">Typing whatever you want to greet below:</p>""")
|
12 |
|
13 |
with gr.Row():
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
btn = gr.Button("Run")
|
18 |
-
btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
|
21 |
demo.launch()
|
|
|
2 |
|
3 |
|
4 |
def greet(name: str) -> str:
|
5 |
+
|
6 |
+
if not name.strip():
|
7 |
+
return gr.update()
|
8 |
+
|
9 |
+
return f"Hello, {name.capitalize()}!"
|
10 |
|
11 |
|
12 |
with gr.Blocks() as demo:
|
|
|
15 |
gr.Markdown("""<p align="center">Typing whatever you want to greet below:</p>""")
|
16 |
|
17 |
with gr.Row():
|
18 |
+
|
19 |
+
user_input = gr.Textbox(
|
20 |
+
value="",
|
21 |
+
label="name",
|
22 |
+
show_label=False,
|
23 |
+
lines=1,
|
24 |
+
max_lines=1,
|
25 |
+
interactive=True,
|
26 |
+
placeholder="World",
|
27 |
+
)
|
28 |
+
|
29 |
+
text_output = gr.Textbox(
|
30 |
+
value="",
|
31 |
+
label="output",
|
32 |
+
show_label=False,
|
33 |
+
lines=1,
|
34 |
+
max_lines=1,
|
35 |
+
interactive=False,
|
36 |
+
)
|
37 |
|
38 |
btn = gr.Button("Run")
|
39 |
+
btn.click(
|
40 |
+
fn=greet,
|
41 |
+
inputs=[user_input],
|
42 |
+
outputs=[text_output],
|
43 |
+
show_progress="hidden",
|
44 |
+
show_api=True,
|
45 |
+
api_name="main",
|
46 |
+
)
|
47 |
|
48 |
|
49 |
demo.launch()
|