terminal / app.py
xcx0902's picture
Create app.py
91e441e verified
raw
history blame
356 Bytes
import gradio as gr
import subprocess
def run(command):
process = subprocess.Popen(list(command.split()), stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
stdout_str, stderr_str = process.communicate()
return f"STDOUT:\n{stdout_str}\nSTDERR:\n{stderr_str}\n"
demo = gr.Interface(fn=run, inputs="text", outputs="text")
demo.launch()