Update index.html
Browse files- index.html +40 -35
index.html
CHANGED
@@ -1,43 +1,48 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
<gradio-lite>
|
15 |
-
import gradio as gr
|
16 |
-
import random
|
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 |
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
+
<head>
|
4 |
+
<script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.js"></script>
|
5 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.css" />
|
6 |
+
<style>
|
7 |
+
body { font-family: Arial, sans-serif; background-color: #f7f1e3; }
|
8 |
+
</style>
|
9 |
+
</head>
|
10 |
+
<body>
|
11 |
+
<gradio-lite>
|
12 |
+
import gradio as gr
|
13 |
+
import random
|
|
|
|
|
|
|
14 |
|
15 |
+
subjects = ['You', 'Your family', 'Your friends', 'A stranger', 'An opportunity']
|
16 |
+
verbs = ['will find', 'may encounter', 'should seek', 'will discover', 'might stumble upon']
|
17 |
+
objects = ['happiness', 'success', 'a challenge', 'love', 'wisdom']
|
18 |
+
timeframes = ['soon', 'in the near future', 'when you least expect it', 'after overcoming an obstacle', 'as a result of your hard work']
|
19 |
|
20 |
+
def generate_fortune(name):
|
21 |
+
fortune = f"{random.choice(subjects)} {random.choice(verbs)} {random.choice(objects)} {random.choice(timeframes)}."
|
22 |
+
if name:
|
23 |
+
return f"{name}, {fortune.lower()}"
|
24 |
+
return fortune
|
25 |
|
26 |
+
def fortune_cookie(name):
|
27 |
+
return generate_fortune(name)
|
28 |
|
29 |
+
with gr.Blocks(title="Fortune Cookie Generator") as demo:
|
30 |
+
gr.Markdown("# 🥠 Fortune Cookie Generator")
|
31 |
+
gr.Markdown("Get your personalized fortune!")
|
32 |
+
|
33 |
+
with gr.Row():
|
34 |
+
name_input = gr.Textbox(label="Enter your name (optional)")
|
35 |
+
fortune_output = gr.Textbox(label="Your Fortune")
|
36 |
+
|
37 |
+
generate_button = gr.Button("Get Fortune")
|
38 |
+
|
39 |
+
generate_button.click(
|
40 |
+
fn=fortune_cookie,
|
41 |
+
inputs=name_input,
|
42 |
+
outputs=fortune_output
|
43 |
+
)
|
44 |
|
45 |
+
demo.launch()
|
46 |
+
</gradio-lite>
|
47 |
+
</body>
|
48 |
</html>
|