Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import subprocess
|
| 3 |
+
|
| 4 |
+
def run_command(cmd):
|
| 5 |
+
try:
|
| 6 |
+
result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=10)
|
| 7 |
+
return result.stdout + "\n" + result.stderr
|
| 8 |
+
except Exception as e:
|
| 9 |
+
return str(e)
|
| 10 |
+
|
| 11 |
+
with gr.Blocks() as demo:
|
| 12 |
+
with gr.Row():
|
| 13 |
+
cmd_input = gr.Textbox(label="Command")
|
| 14 |
+
output = gr.Textbox(label="Output", lines=20)
|
| 15 |
+
cmd_input.submit(run_command, inputs=cmd_input, outputs=output)
|
| 16 |
+
|
| 17 |
+
demo.launch()
|