janiahung commited on
Commit
57a9f28
1 Parent(s): 86451cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py CHANGED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random
3
+
4
+ # 定義抽籤選項
5
+ choices = ["大吉", "中吉", "小吉", "吉", "凶"]
6
+
7
+ # 抽籤函數
8
+ def draw_lot():
9
+ return random.choice(choices)
10
+
11
+ # 建立 Gradio 介面
12
+ with gr.Blocks() as demo:
13
+ gr.Markdown("### 抽籤系統")
14
+ result = gr.Textbox(label="抽籤結果", interactive=False)
15
+ button = gr.Button("抽籤")
16
+
17
+ # 點擊按鈕後,呼叫 draw_lot 函數更新結果
18
+ button.click(fn=draw_lot, inputs=[], outputs=[result])
19
+
20
+ # 啟動 Gradio 介面
21
+ demo.launch()