TiRex-demo / app.py
Nikita
removed app variable
a12343f
raw
history blame
1.52 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.
# 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)