louise840115 commited on
Commit
9ea2177
·
verified ·
1 Parent(s): d7706e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -11
app.py CHANGED
@@ -1,17 +1,22 @@
 
1
  import random
2
 
3
- def draw_lottery(start, end):
4
- return random.randint(start, end)
 
 
 
5
 
6
- def main():
7
- start = 1
8
- end = 35
 
 
 
 
 
9
 
10
- # 抽籤
11
- winner = draw_lottery(start, end)
12
 
13
- print(f"恭喜!獲勝號碼是:{winner}")
14
-
15
- if __name__ == "__main__":
16
- main()
17
 
 
1
+ import gradio as gr
2
  import random
3
 
4
+ def draw_lottery(max_number):
5
+ if max_number < 1:
6
+ return "請輸入一個有效的最大值!"
7
+ winner = random.randint(1, max_number)
8
+ return f"恭喜!獲勝號碼是:{winner}"
9
 
10
+ # 設定 Gradio 介面
11
+ iface = gr.Interface(
12
+ fn=draw_lottery,
13
+ inputs=gr.Number(label="班級座號的最大值", default=35, precision=0),
14
+ outputs="text",
15
+ title="抽籤系統",
16
+ description="輸入班級座號的最大值,然後點擊按鈕進行抽籤。"
17
+ )
18
 
19
+ # 啟動 Gradio 介面
20
+ iface.launch()
21
 
 
 
 
 
22