Update index.html
Browse files- index.html +24 -79
index.html
CHANGED
@@ -1,97 +1,42 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
<head>
|
4 |
-
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto&display=swap">
|
5 |
-
<style>
|
6 |
-
body {
|
7 |
-
font-family: 'Roboto', sans-serif;
|
8 |
-
font-size: 16px;
|
9 |
-
background-color: #f7f1e3;
|
10 |
-
display: flex;
|
11 |
-
justify-content: center;
|
12 |
-
align-items: center;
|
13 |
-
height: 100vh;
|
14 |
-
margin: 0;
|
15 |
-
}
|
16 |
-
.container {
|
17 |
-
background-color: white;
|
18 |
-
padding: 2em;
|
19 |
-
border-radius: 10px;
|
20 |
-
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
21 |
-
max-width: 600px;
|
22 |
-
width: 100%;
|
23 |
-
}
|
24 |
-
h1 {
|
25 |
-
color: #e67e22;
|
26 |
-
text-align: center;
|
27 |
-
}
|
28 |
-
</style>
|
29 |
<script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@gradio/[email protected]/dist/lite.js"></script>
|
30 |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@gradio/[email protected]/dist/lite.css" />
|
31 |
</head>
|
32 |
<body>
|
33 |
-
<
|
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 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
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
|
63 |
if not name.strip():
|
64 |
return "Please enter your name to receive a fortune."
|
65 |
-
|
66 |
-
|
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 |
-
|
77 |
-
|
78 |
-
gr.
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
fortune_output = gr.Textbox(label="Your Fortune", lines=3, interactive=False)
|
85 |
-
|
86 |
-
generate_button.click(
|
87 |
-
fn=generate_fortune,
|
88 |
-
inputs=name_input,
|
89 |
-
outputs=fortune_output
|
90 |
-
)
|
91 |
|
92 |
demo.launch()
|
93 |
-
</gradio-
|
94 |
-
</gradio-lite>
|
95 |
-
</div>
|
96 |
</body>
|
97 |
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
<head>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
<script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@gradio/[email protected]/dist/lite.js"></script>
|
5 |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@gradio/[email protected]/dist/lite.css" />
|
6 |
</head>
|
7 |
<body>
|
8 |
+
<gradio-lite>
|
|
|
|
|
|
|
9 |
import gradio as gr
|
10 |
import random
|
11 |
|
12 |
+
fortunes = [
|
13 |
+
"A pleasant surprise is waiting for you.",
|
14 |
+
"Your hard work will pay off in the near future.",
|
15 |
+
"A new opportunity will present itself soon.",
|
16 |
+
"Your creativity will lead you to success.",
|
17 |
+
"An unexpected journey will bring you joy.",
|
18 |
+
"A wise decision lies ahead of you.",
|
19 |
+
"Your kindness will be rewarded tenfold.",
|
20 |
+
"A long-lost friend will reenter your life.",
|
21 |
+
"Your persistence will overcome current challenges.",
|
22 |
+
"A positive change is on the horizon."
|
23 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
+
def get_fortune(name):
|
26 |
if not name.strip():
|
27 |
return "Please enter your name to receive a fortune."
|
28 |
+
fortune = random.choice(fortunes)
|
29 |
+
return f"{name.strip()}, your fortune: {fortune}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
+
demo = gr.Interface(
|
32 |
+
fn=get_fortune,
|
33 |
+
inputs=gr.Textbox(label="Your Name"),
|
34 |
+
outputs=gr.Textbox(label="Your Fortune"),
|
35 |
+
title="🥠 Simple Fortune Cookie",
|
36 |
+
description="Enter your name to receive a fortune!"
|
37 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
demo.launch()
|
40 |
+
</gradio-lite>
|
|
|
|
|
41 |
</body>
|
42 |
</html>
|