Spaces:
Running
on
T4
Running
on
T4
| 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) | |