Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import random
|
| 3 |
+
|
| 4 |
+
# 定義抽籤功能
|
| 5 |
+
def lottery_draw(max_number):
|
| 6 |
+
# 生成隨機號碼
|
| 7 |
+
return random.randint(1, max_number)
|
| 8 |
+
|
| 9 |
+
# 建立 Gradio 介面
|
| 10 |
+
with gr.Blocks() as demo:
|
| 11 |
+
gr.Markdown("# 抽籤系統")
|
| 12 |
+
|
| 13 |
+
max_number_input = gr.Number(label="輸入班級座號的最大值", value=30)
|
| 14 |
+
draw_button = gr.Button("抽籤")
|
| 15 |
+
result = gr.Textbox(label="抽中的號碼")
|
| 16 |
+
|
| 17 |
+
# 點擊按鈕後執行抽籤
|
| 18 |
+
draw_button.click(lottery_draw, inputs=max_number_input, outputs=result)
|
| 19 |
+
|
| 20 |
+
# 啟動介面
|
| 21 |
+
demo.launch()
|