TiRex-demo / app.py
Nikita
test gradio app
3a282ff
raw
history blame
1.44 kB
# 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()