janiahung's picture
Update app.py
57a9f28 verified
raw
history blame
522 Bytes
import gradio as gr
import random
# 定義抽籤選項
choices = ["大吉", "中吉", "小吉", "吉", "凶"]
# 抽籤函數
def draw_lot():
return random.choice(choices)
# 建立 Gradio 介面
with gr.Blocks() as demo:
gr.Markdown("### 抽籤系統")
result = gr.Textbox(label="抽籤結果", interactive=False)
button = gr.Button("抽籤")
# 點擊按鈕後,呼叫 draw_lot 函數更新結果
button.click(fn=draw_lot, inputs=[], outputs=[result])
# 啟動 Gradio 介面
demo.launch()