youngtsai commited on
Commit
9331b9a
·
verified ·
1 Parent(s): 87842be

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random
2
+ import gradio as gr
3
+
4
+ # 定義抽籤功能
5
+ def draw_lottery(max_number):
6
+ return random.randint(1, max_number)
7
+
8
+ # 定義 Gradio 介面
9
+ with gr.Blocks() as demo:
10
+ gr.Markdown("## 班級座號抽籤系統")
11
+ max_number_input = gr.Number(label="請輸入班級座號的最大值", value=50)
12
+ draw_button = gr.Button("開始抽籤")
13
+ result = gr.Textbox(label="抽出的號碼")
14
+
15
+ # 綁定按鈕事件
16
+ draw_button.click(fn=draw_lottery, inputs=max_number_input, outputs=result)
17
+
18
+ # 啟動 Gradio 介面
19
+ demo.launch()