akhaliq HF staff commited on
Commit
d17398d
·
verified ·
1 Parent(s): 4740d25

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +7 -7
index.html CHANGED
@@ -9,16 +9,16 @@
9
  import gradio as gr
10
  import random
11
 
12
- subjects = ['You', 'Your family', 'Your friends', 'A stranger', 'An opportunity']
13
  verbs = ['will find', 'may encounter', 'should seek', 'will discover', 'might stumble upon']
14
  objects = ['happiness', 'success', 'a challenge', 'love', 'wisdom']
15
  timeframes = ['soon', 'in the near future', 'when you least expect it', 'after overcoming an obstacle', 'as a result of your hard work']
16
 
17
  def generate_fortune(name):
 
 
18
  fortune = f"{random.choice(subjects)} {random.choice(verbs)} {random.choice(objects)} {random.choice(timeframes)}."
19
- if name:
20
- return f"{name}, {fortune.lower()}"
21
- return fortune
22
 
23
  with gr.Blocks(
24
  title="Fortune Cookie Generator",
@@ -35,13 +35,13 @@ with gr.Blocks(
35
  )
36
  ) as demo:
37
  gr.Markdown("# 🥠 Fortune Cookie Generator")
38
- gr.Markdown("Crack open your digital fortune cookie and discover what the future holds!")
39
 
40
  with gr.Row():
41
- name_input = gr.Textbox(label="Enter your name (optional)", placeholder="Your name here...", scale=3)
42
  generate_button = gr.Button("🔮 Reveal Your Fortune", variant="primary", scale=1)
43
 
44
- fortune_output = gr.Textbox(label="Your Fortune", placeholder="Your fortune will appear here...", interactive=False)
45
 
46
  generate_button.click(
47
  fn=generate_fortune,
 
9
  import gradio as gr
10
  import random
11
 
12
+ subjects = ['you', 'your family', 'your friends', 'a stranger', 'an opportunity']
13
  verbs = ['will find', 'may encounter', 'should seek', 'will discover', 'might stumble upon']
14
  objects = ['happiness', 'success', 'a challenge', 'love', 'wisdom']
15
  timeframes = ['soon', 'in the near future', 'when you least expect it', 'after overcoming an obstacle', 'as a result of your hard work']
16
 
17
  def generate_fortune(name):
18
+ if not name.strip():
19
+ return "Please enter your name to receive a fortune."
20
  fortune = f"{random.choice(subjects)} {random.choice(verbs)} {random.choice(objects)} {random.choice(timeframes)}."
21
+ return f"{name.strip()}, {fortune}"
 
 
22
 
23
  with gr.Blocks(
24
  title="Fortune Cookie Generator",
 
35
  )
36
  ) as demo:
37
  gr.Markdown("# 🥠 Fortune Cookie Generator")
38
+ gr.Markdown("Enter your name and crack open your personalized digital fortune cookie!")
39
 
40
  with gr.Row():
41
+ name_input = gr.Textbox(label="Enter your name", placeholder="Your name here...", scale=3)
42
  generate_button = gr.Button("🔮 Reveal Your Fortune", variant="primary", scale=1)
43
 
44
+ fortune_output = gr.Textbox(label="Your Fortune", placeholder="Your personalized fortune will appear here...", interactive=False)
45
 
46
  generate_button.click(
47
  fn=generate_fortune,