File size: 2,686 Bytes
8032eaf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52990df
8032eaf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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"""
    <div style='text-align: center; animation: fadeIn 1s;'>
        <h1 style='color: #2E86C1; font-size: 2.5em; text-shadow: 2px 2px 4px rgba(0,0,0,0.2);'>
            {greeting}, {name}! 🌟
        </h1>
        <p style='color: #666; font-style: italic;'>
            Current time: {current_time}
        </p>
        <div style='margin: 20px; padding: 15px; background: linear-gradient(45deg, #E8F8F5, #D4E6F1); border-radius: 10px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);'>
            <p>Thank you for visiting! Have a wonderful day! ✨</p>
        </div>
    </div>
    
    <style>
    @keyframes fadeIn {{
        from {{ opacity: 0; transform: translateY(-20px); }}
        to {{ opacity: 1; transform: translateY(0); }}
    }}
    </style>
    """
    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()