Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,22 @@
|
|
|
|
1 |
import random
|
2 |
|
3 |
-
def draw_lottery(
|
4 |
-
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
-
|
11 |
-
|
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 |
|