akhaliq HF staff commited on
Commit
581122e
·
verified ·
1 Parent(s): 25f01a4

Update index.html

Browse files
Files changed (1) hide show
  1. 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
- <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,
88
- inputs=name_input,
89
- outputs=fortune_output
90
- )
91
 
92
  demo.launch()
93
- </gradio-file>
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>