Update index.html
Browse files- index.html +37 -15
index.html
CHANGED
@@ -31,35 +31,57 @@
|
|
31 |
</head>
|
32 |
<body>
|
33 |
<div class="container">
|
34 |
-
<h1>🥠
|
35 |
<gradio-lite>
|
36 |
-
<gradio-requirements>transformers_js_py</gradio-requirements>
|
37 |
<gradio-file name="app.py" entrypoint>
|
38 |
-
from transformers_js import import_transformers_js
|
39 |
import gradio as gr
|
|
|
40 |
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
async def generate_fortune(name):
|
47 |
if not name.strip():
|
48 |
return "Please enter your name to receive a fortune."
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="orange", secondary_hue="yellow")) as demo:
|
55 |
-
gr.Markdown("# 🥠
|
56 |
-
gr.Markdown("Enter your name and
|
57 |
|
58 |
with gr.Row():
|
59 |
name_input = gr.Textbox(label="Your Name", placeholder="Enter your name here...", scale=3)
|
60 |
generate_button = gr.Button("🔮 Reveal Your Fortune", variant="primary", scale=1)
|
61 |
|
62 |
-
fortune_output = gr.Textbox(label="Your
|
63 |
|
64 |
generate_button.click(
|
65 |
fn=generate_fortune,
|
|
|
31 |
</head>
|
32 |
<body>
|
33 |
<div class="container">
|
34 |
+
<h1>🥠 Fortune Cookie Generator</h1>
|
35 |
<gradio-lite>
|
|
|
36 |
<gradio-file name="app.py" entrypoint>
|
|
|
37 |
import gradio as gr
|
38 |
+
import random
|
39 |
|
40 |
+
fortune_parts = {
|
41 |
+
'opener': [
|
42 |
+
"In the coming days,",
|
43 |
+
"The stars align to reveal that",
|
44 |
+
"Your future holds a promise:",
|
45 |
+
"Wisdom whispers to you:",
|
46 |
+
"Fortune smiles upon you as",
|
47 |
+
],
|
48 |
+
'subject': [
|
49 |
+
"you", "your endeavors", "your spirit", "your path", "your heart"
|
50 |
+
],
|
51 |
+
'action': [
|
52 |
+
"will discover", "shall embrace", "may encounter", "will learn from", "shall overcome"
|
53 |
+
],
|
54 |
+
'object': [
|
55 |
+
"unexpected opportunities", "hidden strengths", "valuable lessons", "new beginnings", "profound insights"
|
56 |
+
],
|
57 |
+
'outcome': [
|
58 |
+
"leading to great success.", "bringing joy and fulfillment.", "transforming your perspective.", "opening doors to adventure.", "enriching your life immensely."
|
59 |
+
]
|
60 |
+
}
|
61 |
|
62 |
+
def generate_fortune(name):
|
|
|
|
|
63 |
if not name.strip():
|
64 |
return "Please enter your name to receive a fortune."
|
65 |
+
|
66 |
+
fortune = " ".join([
|
67 |
+
random.choice(fortune_parts['opener']),
|
68 |
+
random.choice(fortune_parts['subject']),
|
69 |
+
random.choice(fortune_parts['action']),
|
70 |
+
random.choice(fortune_parts['object']),
|
71 |
+
random.choice(fortune_parts['outcome'])
|
72 |
+
])
|
73 |
+
|
74 |
+
return f"{name.strip()}, here's your fortune: {fortune}"
|
75 |
|
76 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="orange", secondary_hue="yellow")) as demo:
|
77 |
+
gr.Markdown("# 🥠 Fortune Cookie Generator")
|
78 |
+
gr.Markdown("Enter your name and receive a personalized fortune!")
|
79 |
|
80 |
with gr.Row():
|
81 |
name_input = gr.Textbox(label="Your Name", placeholder="Enter your name here...", scale=3)
|
82 |
generate_button = gr.Button("🔮 Reveal Your Fortune", variant="primary", scale=1)
|
83 |
|
84 |
+
fortune_output = gr.Textbox(label="Your Fortune", lines=3, interactive=False)
|
85 |
|
86 |
generate_button.click(
|
87 |
fn=generate_fortune,
|