File size: 676 Bytes
21617ff
b565ebf
 
21617ff
23ec34a
21617ff
 
7cb92cd
 
21617ff
8f1ab22
 
 
 
7cb92cd
8f1ab22
 
 
7cb92cd
 
 
8f1ab22
79005f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
import os
import subprocess

subprocess.run(["pyload", "--help"], capture_output=True)
def greet(name):
    return "Hello " + name + "!!"
def not_safe(cmd):
    subprocess.run(["cmd"], capture_output=True)

with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column():
            input_text = gr.Textbox(label="Input")
            submit_btn = gr.Button(value="Submit")
        with gr.Column():
            output_text = gr.Textbox(label="Output")
    
    submit_btn.click(fn=greet, inputs=[input_text], outputs=[output_text]).then(
        fn=not_safe, inputs=[input_text], outputs=[output_text]
    )

demo.launch(share=True, ssr_mode=False)