Spaces:
Running
Running
File size: 1,056 Bytes
70a2fe4 f6233b7 70a2fe4 24dd87b f6233b7 70a2fe4 5fb9f59 |
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 32 33 34 35 36 37 |
import gradio as gr
import random
with gr.Blocks() as demo:
name = gr.Textbox(label="Name")
output = gr.Textbox(label="Output Box")
greet_btn = gr.Button("Greet")
@gr.on([greet_btn.click, name.submit], inputs=name, outputs=output)
def greet(name):
return "Hello " + name + "!"
with demo.route("Up") as incrementer_demo:
num = gr.Number()
incrementer_demo.load(lambda: random.randint(10, 40), None, num)
with gr.Row():
inc_btn = gr.Button("Increase")
dec_btn = gr.Button("Decrease")
inc_btn.click(fn=lambda x: x + 1, inputs=num, outputs=num, api_name="increment")
dec_btn.click(fn=lambda x: x - 1, inputs=num, outputs=num, api_name="decrement")
for i in range(100):
gr.Textbox()
def wait(x):
import time
time.sleep(2)
return x
identity_iface = gr.Interface(wait, "image", "image")
with demo.route("Interface") as incrementer_demo:
identity_iface.render()
gr.ChatInterface(lambda *args: "Hello")
if __name__ == "__main__":
demo.launch(ssr_mode=False)
|