Spaces:
Running
Running
File size: 833 Bytes
d4fa759 96bcc4a d4fa759 00a5428 96bcc4a 00a5428 d4fa759 96bcc4a 0ddab14 00a5428 96bcc4a d4fa759 00a5428 d4fa759 96bcc4a 00a5428 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import subprocess
import gradio as gr
def infer(command):
status = "Success"
result = None
try:
result = subprocess.check_output(
command,
shell=True,
stderr=subprocess.STDOUT,
text=True,
)
except Exception as e:
status = f"Error: {e.output}"
return status, result
if __name__ == "__main__":
gr.Interface(
fn=infer,
inputs=gr.Textbox(label="Linux Command", value="ls"),
outputs=[
gr.Textbox(label="Status", show_copy_button=True),
gr.TextArea(label="Command Output", show_copy_button=True),
],
title="Linux Command Executor",
description="Enter a Linux command and click submit to see the output.",
flagging_mode="never",
).launch(ssr_mode=False)
|