abidlabs HF Staff commited on
Commit
f6233b7
·
verified ·
1 Parent(s): 4cc4a74

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -6
app.py CHANGED
@@ -1,11 +1,36 @@
1
  import gradio as gr
2
-
3
- import main_page, second_page
4
 
5
  with gr.Blocks() as demo:
6
- main_page.demo.render()
7
- with demo.route("Second Page"):
8
- second_page.demo.render()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  if __name__ == "__main__":
11
- demo.launch(ssr_mode=False)
 
1
  import gradio as gr
2
+ import random
 
3
 
4
  with gr.Blocks() as demo:
5
+ name = gr.Textbox(label="Name")
6
+ output = gr.Textbox(label="Output Box")
7
+ greet_btn = gr.Button("Greet")
8
+ @gr.on([greet_btn.click, name.submit], inputs=name, outputs=output)
9
+ def greet(name):
10
+ return "Hello " + name + "!"
11
+
12
+ with demo.route("Up") as incrementer_demo:
13
+ num = gr.Number()
14
+ incrementer_demo.load(lambda: random.randint(10, 40), None, num)
15
+
16
+ with gr.Row():
17
+ inc_btn = gr.Button("Increase")
18
+ dec_btn = gr.Button("Decrease")
19
+ inc_btn.click(fn=lambda x: x + 1, inputs=num, outputs=num, api_name="increment")
20
+ dec_btn.click(fn=lambda x: x - 1, inputs=num, outputs=num, api_name="decrement")
21
+ for i in range(100):
22
+ gr.Textbox()
23
+
24
+ def wait(x):
25
+ import time
26
+ time.sleep(2)
27
+ return x
28
+
29
+ identity_iface = gr.Interface(wait, "image", "image")
30
+
31
+ with demo.route("Interface") as incrementer_demo:
32
+ identity_iface.render()
33
+ gr.ChatInterface(lambda *args: "Hello")
34
 
35
  if __name__ == "__main__":
36
+ demo.launch()