Update index.html
Browse files- index.html +7 -7
index.html
CHANGED
@@ -9,16 +9,16 @@
|
|
9 |
import gradio as gr
|
10 |
import random
|
11 |
|
12 |
-
subjects = ['
|
13 |
verbs = ['will find', 'may encounter', 'should seek', 'will discover', 'might stumble upon']
|
14 |
objects = ['happiness', 'success', 'a challenge', 'love', 'wisdom']
|
15 |
timeframes = ['soon', 'in the near future', 'when you least expect it', 'after overcoming an obstacle', 'as a result of your hard work']
|
16 |
|
17 |
def generate_fortune(name):
|
|
|
|
|
18 |
fortune = f"{random.choice(subjects)} {random.choice(verbs)} {random.choice(objects)} {random.choice(timeframes)}."
|
19 |
-
|
20 |
-
return f"{name}, {fortune.lower()}"
|
21 |
-
return fortune
|
22 |
|
23 |
with gr.Blocks(
|
24 |
title="Fortune Cookie Generator",
|
@@ -35,13 +35,13 @@ with gr.Blocks(
|
|
35 |
)
|
36 |
) as demo:
|
37 |
gr.Markdown("# 🥠 Fortune Cookie Generator")
|
38 |
-
gr.Markdown("
|
39 |
|
40 |
with gr.Row():
|
41 |
-
name_input = gr.Textbox(label="Enter your name
|
42 |
generate_button = gr.Button("🔮 Reveal Your Fortune", variant="primary", scale=1)
|
43 |
|
44 |
-
fortune_output = gr.Textbox(label="Your Fortune", placeholder="Your fortune will appear here...", interactive=False)
|
45 |
|
46 |
generate_button.click(
|
47 |
fn=generate_fortune,
|
|
|
9 |
import gradio as gr
|
10 |
import random
|
11 |
|
12 |
+
subjects = ['you', 'your family', 'your friends', 'a stranger', 'an opportunity']
|
13 |
verbs = ['will find', 'may encounter', 'should seek', 'will discover', 'might stumble upon']
|
14 |
objects = ['happiness', 'success', 'a challenge', 'love', 'wisdom']
|
15 |
timeframes = ['soon', 'in the near future', 'when you least expect it', 'after overcoming an obstacle', 'as a result of your hard work']
|
16 |
|
17 |
def generate_fortune(name):
|
18 |
+
if not name.strip():
|
19 |
+
return "Please enter your name to receive a fortune."
|
20 |
fortune = f"{random.choice(subjects)} {random.choice(verbs)} {random.choice(objects)} {random.choice(timeframes)}."
|
21 |
+
return f"{name.strip()}, {fortune}"
|
|
|
|
|
22 |
|
23 |
with gr.Blocks(
|
24 |
title="Fortune Cookie Generator",
|
|
|
35 |
)
|
36 |
) as demo:
|
37 |
gr.Markdown("# 🥠 Fortune Cookie Generator")
|
38 |
+
gr.Markdown("Enter your name and crack open your personalized digital fortune cookie!")
|
39 |
|
40 |
with gr.Row():
|
41 |
+
name_input = gr.Textbox(label="Enter your name", placeholder="Your name here...", scale=3)
|
42 |
generate_button = gr.Button("🔮 Reveal Your Fortune", variant="primary", scale=1)
|
43 |
|
44 |
+
fortune_output = gr.Textbox(label="Your Fortune", placeholder="Your personalized fortune will appear here...", interactive=False)
|
45 |
|
46 |
generate_button.click(
|
47 |
fn=generate_fortune,
|