Browen0311 commited on
Commit
955f4ce
·
verified ·
1 Parent(s): 68d91de

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
+ def draw_lottery(max_number):
5
+ return random.randint(1, max_number)
6
+
7
+ with gr.Blocks() as demo:
8
+ # 班級座號最大值輸入框
9
+ max_number_input = gr.Number(label="班級座號最大值", value=50)
10
+
11
+ # 抽籤按鈕與結果顯示
12
+ draw_button = gr.Button("抽籤")
13
+ result_output = gr.Textbox(label="抽中的號碼", interactive=False)
14
+
15
+ # 點擊按鈕時執行抽籤函數
16
+ draw_button.click(fn=draw_lottery,
17
+ inputs=max_number_input,
18
+ outputs=result_output)
19
+
20
+ # 啟動介面
21
+ demo.launch()