akhaliq HF staff commited on
Commit
9f12d53
·
verified ·
1 Parent(s): 877dbae

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +40 -35
index.html CHANGED
@@ -1,43 +1,48 @@
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 {
8
- font-family: Arial, sans-serif;
9
- background-color: #f7f1e3;
10
- }
11
- </style>
12
- </head>
13
- <body>
14
- <gradio-lite>
15
- import gradio as gr
16
- import random
17
 
18
- subjects = ['You', 'Your family', 'Your friends', 'A stranger', 'An opportunity']
19
- verbs = ['will find', 'may encounter', 'should seek', 'will discover', 'might stumble upon']
20
- objects = ['happiness', 'success', 'a challenge', 'love', 'wisdom']
21
- timeframes = ['soon', 'in the near future', 'when you least expect it', 'after overcoming an obstacle', 'as a result of your hard work']
22
 
23
- def generate_fortune(name):
24
- fortune = f"{random.choice(subjects)} {random.choice(verbs)} {random.choice(objects)} {random.choice(timeframes)}."
25
- if name:
26
- return f"{name}, {fortune.lower()}"
27
- return fortune
28
 
29
- def fortune_cookie(name):
30
- return generate_fortune(name)
31
 
32
- iface = gr.Interface(
33
- fn=fortune_cookie,
34
- inputs=gr.Textbox(label="Enter your name (optional)"),
35
- outputs=gr.Textbox(label="Your Fortune"),
36
- title="Fortune Cookie Generator",
37
- description="Get your personalized fortune!",
38
- )
 
 
 
 
 
 
 
 
39
 
40
- iface.launch()
41
- </gradio-lite>
42
- </body>
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>