Spaces:
Running
on
T4
Running
on
T4
File size: 1,519 Bytes
3a282ff 6e15efd 6a22c5c b8f5692 76a84b9 3a282ff 8623916 3a282ff 9568aba 8623916 6e15efd 9568aba 6e15efd 3a282ff 6e15efd 9568aba 3a282ff 8623916 6e15efd 9568aba 3a282ff 9568aba 3a282ff 6e15efd 9568aba |
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 40 41 42 |
import gradio as gr
import time # Import time to make logs more distinct
import groq
import piskasiska
def greet(name):
"""
This function takes a name as input and returns a personalized greeting string.
It now includes print statements for logging with flush=True to ensure
logs appear immediately in container environments like Hugging Face Spaces.
"""
# Log the function entry
# The flush=True argument is crucial for logs to appear in real-time in Docker.
print(f"[{time.ctime()}] - Function 'greet' was called.", flush=True)
if name:
# Log the received input
print(f"[{time.ctime()}] - Received input name: '{name}'", flush=True)
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.", flush=True)
return "Hello! Please enter your name."
# Create the Gradio interface
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 with Logging",
description="Enter your name to receive a greeting. Check the Hugging Face logs to see the output from the print() statements."
)
# Launch the application
if __name__ == "__main__":
print(f"[{time.ctime()}] - Starting Gradio server...", flush=True)
app.launch(server_name="0.0.0.0", server_port=7860)
|