File size: 1,522 Bytes
3a282ff
 
 
76a84b9
3a282ff
76a84b9
3a282ff
8623916
3a282ff
8623916
3a282ff
 
8623916
3a282ff
 
 
 
 
 
 
 
 
a12343f
 
 
 
 
 
 
3a282ff
 
 
 
 
 
 
 
2cef216
a12343f
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.

# Launch the application
# To run in a Docker container (like on Hugging Face Spaces), you must
# set server_name="0.0.0.0" to listen on all network interfaces.
# The server_port should match the port exposed in your Dockerfile and readme.md (7860).
if __name__ == "__main__":
    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."
).launch(server_name="0.0.0.0", server_port=7860)