testVariable / app.py
eternalBlissard's picture
Update app.py
a66cb80 verified
raw
history blame contribute delete
542 Bytes
import gradio as gr
def respond(newVal, previous_val):
if previous_val is None:
previous_val = newVal
return previous_val
with gr.Blocks() as demo:
val = gr.State(None)
input_text = gr.Textbox(label="Input")
output_text = gr.Textbox(label="Output")
submit_button = gr.Button("Submit")
def on_submit(newVal, previous_val):
updated_val = respond(newVal, previous_val)
return updated_val, updated_val
submit_button.click(on_submit, [input_text, val], [val, output_text])
demo.launch()