File size: 1,601 Bytes
6b3be9d
ebe1056
9f12d53
 
 
 
 
 
 
 
 
 
 
ebe1056
9f12d53
 
 
 
ebe1056
9f12d53
 
 
 
 
ebe1056
9f12d53
 
ebe1056
9f12d53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ebe1056
9f12d53
 
 
ebe1056
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
<!DOCTYPE html>
<html>
<head>
    <script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.css" />
    <style>
        body { font-family: Arial, sans-serif; background-color: #f7f1e3; }
    </style>
</head>
<body>
    <gradio-lite>
import gradio as gr
import random

subjects = ['You', 'Your family', 'Your friends', 'A stranger', 'An opportunity']
verbs = ['will find', 'may encounter', 'should seek', 'will discover', 'might stumble upon']
objects = ['happiness', 'success', 'a challenge', 'love', 'wisdom']
timeframes = ['soon', 'in the near future', 'when you least expect it', 'after overcoming an obstacle', 'as a result of your hard work']

def generate_fortune(name):
    fortune = f"{random.choice(subjects)} {random.choice(verbs)} {random.choice(objects)} {random.choice(timeframes)}."
    if name:
        return f"{name}, {fortune.lower()}"
    return fortune

def fortune_cookie(name):
    return generate_fortune(name)

with gr.Blocks(title="Fortune Cookie Generator") as demo:
    gr.Markdown("# 🥠 Fortune Cookie Generator")
    gr.Markdown("Get your personalized fortune!")
    
    with gr.Row():
        name_input = gr.Textbox(label="Enter your name (optional)")
        fortune_output = gr.Textbox(label="Your Fortune")
    
    generate_button = gr.Button("Get Fortune")
    
    generate_button.click(
        fn=fortune_cookie,
        inputs=name_input,
        outputs=fortune_output
    )

demo.launch()
    </gradio-lite>
</body>
</html>