File size: 618 Bytes
77d776a
 
 
 
 
 
ed89419
6fd8c5d
ed89419
 
77d776a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import gradio as gr
import time

def count(n):
    for i in range(int(n)):
        time.sleep(0.5)
        if i == 2:
            raise Exception("foo!")
        else:
            yield i

def show(n):
    return str(list(range(int(n))))

with gr.Blocks() as demo:
    with gr.Column():
        num = gr.Number(value=10)
        with gr.Row():
            count_btn = gr.Button("Count")
            list_btn = gr.Button("List")
    with gr.Column():
        out = gr.Textbox()
    
    count_btn.click(count, num, out)
    list_btn.click(show, num, out)
    
demo.queue()

if __name__ == "__main__":
    demo.launch()