app.py
Browse filesimport gradio as gr
def greet(name):
if not name:
return "Please enter a valid name."
return f"Hello, {name}!"
iface = gr.Interface(
fn=greet,
inputs=gr.inputs.Textbox(lines=1, placeholder="Enter your name here..."),
outputs="text",
title="Greeting App",
description="Enter your name and receive a greeting!",
live=True
)
if __name__ == "__main__":
try:
iface.launch()
except Exception as e:
print(f"An error occurred: {e}")
app.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
def greet(name):
|
|
|
|
|
|
|
| 4 |
return f"Hello, {name}!"
|
| 5 |
|
| 6 |
iface = gr.Interface(
|
|
@@ -8,7 +10,12 @@ iface = gr.Interface(
|
|
| 8 |
inputs=gr.inputs.Textbox(lines=1, placeholder="Enter your name here..."),
|
| 9 |
outputs="text",
|
| 10 |
title="Greeting App",
|
| 11 |
-
description="Enter your name and receive a greeting!"
|
|
|
|
| 12 |
)
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
def greet(name):
|
| 4 |
+
if not name:
|
| 5 |
+
return "Please enter a valid name."
|
| 6 |
return f"Hello, {name}!"
|
| 7 |
|
| 8 |
iface = gr.Interface(
|
|
|
|
| 10 |
inputs=gr.inputs.Textbox(lines=1, placeholder="Enter your name here..."),
|
| 11 |
outputs="text",
|
| 12 |
title="Greeting App",
|
| 13 |
+
description="Enter your name and receive a greeting!",
|
| 14 |
+
live=True
|
| 15 |
)
|
| 16 |
|
| 17 |
+
if __name__ == "__main__":
|
| 18 |
+
try:
|
| 19 |
+
iface.launch()
|
| 20 |
+
except Exception as e:
|
| 21 |
+
print(f"An error occurred: {e}")
|