Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import random | |
| # 定義抽籤功能 | |
| def lottery_draw(max_number): | |
| # 生成隨機號碼 | |
| return random.randint(1, max_number) | |
| # 建立 Gradio 介面 | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# 抽籤系統") | |
| max_number_input = gr.Number(label="輸入班級座號的最大值", value=30) | |
| draw_button = gr.Button("抽籤") | |
| result = gr.Textbox(label="抽中的號碼") | |
| # 點擊按鈕後執行抽籤 | |
| draw_button.click(lottery_draw, inputs=max_number_input, outputs=result) | |
| # 啟動介面 | |
| demo.launch() | |