eternalBlissard commited on
Commit
5c42fbb
·
verified ·
1 Parent(s): 4f5cc0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -1,16 +1,16 @@
1
  import gradio as gr
2
 
3
- val = gr.State(None)
4
- def respond(newVal):
5
- global val
6
- if(val is None):
7
- val = newVal
8
- return val
9
 
10
- demo = gr.Interface(fn=respond,
11
- inputs = [gr.Textbox()],
12
- outputs= [gr.Textbox()],
13
- title = 'testVar')
14
- demo.launch()
15
 
16
-
 
 
 
 
1
  import gradio as gr
2
 
3
+ def respond(newVal, previous_val):
4
+ if previous_val is None:
5
+ previous_val = newVal
6
+ return previous_val
 
 
7
 
8
+ with gr.Blocks() as demo:
9
+ val = gr.State(None)
10
+ input_text = gr.Textbox(label="Input")
11
+ output_text = gr.Textbox(label="Output")
 
12
 
13
+ input_text.change(respond, [input_text, val], val)
14
+ val.change(lambda val: val, val, output_text)
15
+
16
+ demo.launch()