Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import random | |
| def draw_lottery(max_number): | |
| return random.randint(1, int(max_number)) | |
| # 創建輸入框來輸入班級座號的最大值 | |
| max_number_input = gr.Number(label="班級座號的最大值") | |
| # 創建輸出框來顯示抽中的號碼 | |
| output_number = gr.Textbox(label="抽中的號碼") | |
| # 定義界面佈局 | |
| interface = gr.Interface( | |
| fn=draw_lottery, | |
| inputs=max_number_input, | |
| outputs=output_number, | |
| title="抽籤系統", | |
| description="輸入班級座號的最大值,點擊抽籤按鈕隨機抽出一個號碼" | |
| ) | |
| # 運行界面 | |
| interface.launch() |