geneh commited on
Commit
70e59aa
·
verified ·
1 Parent(s): 13131da

First commit

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
+ def draw_lottery(max_number):
6
+ if max_number <= 0:
7
+ return "請輸入一個正整數"
8
+ return random.randint(1, max_number)
9
+
10
+ # 創建 Gradio 介面
11
+ with gr.Blocks() as demo:
12
+ with gr.Row():
13
+ max_number_input = gr.Number(label="班級座號的最大值", value=40, precision=0)
14
+ result_output = gr.Textbox(label="抽中的號碼")
15
+
16
+ draw_button = gr.Button("抽籤")
17
+
18
+ draw_button.click(draw_lottery, inputs=max_number_input, outputs=result_output)
19
+
20
+ # 啟動介面
21
+ demo.launch()