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

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +11 -10
index.html CHANGED
@@ -9,7 +9,7 @@
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.",
@@ -25,18 +25,19 @@ fortunes = [
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>
 
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.",
 
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
+ with gr.Blocks() as demo:
32
+ gr.Markdown("# 🥠 Fortune Cookie Generator")
33
+ name_input = gr.Textbox(label="Your Name")
34
+ fortune_output = gr.Textbox(label="Your Fortune")
35
+ submit_button = gr.Button("Get Fortune")
36
+
37
+ submit_button.click(fn=get_fortune, inputs=name_input, outputs=fortune_output)
38
 
39
+ if __name__ == "__main__":
40
+ demo.launch()
41
  </gradio-lite>
42
  </body>
43
  </html>