import gradio as gr import time from datetime import datetime def greet(name, language): if not name: name = "World" greetings = { "English": "Hello", "Spanish": "¡Hola", "French": "Bonjour", "Japanese": "こんにちは", "German": "Hallo" } # Get current time current_time = datetime.now().strftime("%H:%M:%S") # Add a small delay for animation effect time.sleep(0.5) greeting = greetings.get(language, "Hello") message = f"""

{greeting}, {name}! 🌟

Current time: {current_time}

Thank you for visiting! Have a wonderful day! ✨

""" return message # Create the Gradio interface with a custom theme custom_css = """ .gradio-container { background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); } """ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo: gr.Markdown( """ # ✨ Fancy Hello World Generator ✨ Create beautiful personalized greetings in different languages! """ ) with gr.Row(): with gr.Column(): name_input = gr.Textbox( label="Enter your name", placeholder="Type your name here...", lines=1 ) language_input = gr.Dropdown( choices=["English", "Spanish", "French", "Japanese", "German", "Chinese"], label="Select Language", value="English" ) greet_btn = gr.Button("Generate Greeting!", variant="primary") with gr.Column(): output = gr.HTML(label="Your Fancy Greeting") greet_btn.click( fn=greet, inputs=[name_input, language_input], outputs=output ) gr.Markdown( """ ### 🌈 Features - Multiple language support - Real-time clock - Smooth animations - Beautiful gradient design """ ) if __name__ == "__main__": demo.launch()