File size: 1,438 Bytes
3a282ff
 
 
76a84b9
3a282ff
76a84b9
3a282ff
8623916
3a282ff
8623916
3a282ff
 
8623916
3a282ff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7fb6e58
dd32739
3a282ff
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# First, you need to install the gradio library if you haven't already.
# You can do this by running the following command in your terminal:
# pip install gradio

import gradio as gr

def greet(name):
    """
    This function takes a name as input and returns a personalized greeting string.
    """
    if name:
        return f"Hello, {name}! Welcome to your first Gradio app."
    else:
        return "Hello! Please enter your name."

# Create the Gradio interface
# gr.Interface is the main class used to build the UI.
# - fn: The function that the interface will call.
# - inputs: The component(s) for user input. Here we use a Textbox.
# - outputs: The component(s) to display the result. Here we use a simple Text component.
# - title: The title that appears at the top of the UI.
# - description: A brief description of what the app does.
app = gr.Interface(
    fn=greet,
    inputs=gr.Textbox(
        lines=1, 
        placeholder="Please enter your name here...", 
        label="Your Name"
    ),
    outputs=gr.Text(label="Greeting"),
    title="Simple Greeting App",
    description="A simple test application built with Python and Gradio. Enter your name to receive a greeting.",
    allow_flagging="never" # Disables the "Flag" button for this simple example
)

# Launch the application
# The launch() method starts a local web server and provides a public URL if share=True.
if __name__ == "__main__":
    app.launch()