TiRex-demo / app.py
Nikita
logs in test
6e15efd
raw
history blame
1.24 kB
import gradio as gr
import time # Import time to make logs more distinct
def greet(name):
"""
This function takes a name as input and returns a personalized greeting string.
It now includes print statements for logging.
"""
# Log the function entry
print(f"[{time.ctime()}] - Function 'greet' was called.")
if name:
# Log the received input
print(f"[{time.ctime()}] - Received input name: '{name}'")
return f"Hello, {name}! Welcome to your first Gradio app."
else:
# Log that the input was empty
print(f"[{time.ctime()}] - No input name received.")
return "Hello! Please enter your name."
# Create the Gradio interface
# Launch the application
if __name__ == "__main__":
print(f"[{time.ctime()}] - Starting Gradio server...")
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 with Logging",
description="Enter your name to receive a greeting. Check the Hugging Face logs to see the output from the print() statements."
).launch(server_name="0.0.0.0", server_port=7860)