Spaces:
Running
on
T4
Running
on
T4
File size: 1,241 Bytes
3a282ff 6e15efd 76a84b9 3a282ff 8623916 3a282ff 6e15efd 8623916 6e15efd 3a282ff 6e15efd 3a282ff 8623916 6e15efd 3a282ff a12343f 6e15efd a12343f 3a282ff 6e15efd 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 |
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) |