eduxgpt commited on
Commit
1c00a6d
·
verified ·
1 Parent(s): 779f355

import 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}")

Files changed (1) hide show
  1. app.py +9 -2
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
- iface.launch(
 
 
 
 
 
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}")