Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import subprocess
|
3 |
+
|
4 |
+
def run_command(command):
|
5 |
+
try:
|
6 |
+
result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
|
7 |
+
return result.stdout
|
8 |
+
except subprocess.CalledProcessError as e:
|
9 |
+
return f"Error: {e.stderr}"
|
10 |
+
|
11 |
+
def terminal_interface(command):
|
12 |
+
return run_command(command)
|
13 |
+
|
14 |
+
iface = gr.Interface(
|
15 |
+
fn=terminal_interface,
|
16 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter your command here..."),
|
17 |
+
outputs="text",
|
18 |
+
title="Docker Command Runner",
|
19 |
+
description="Enter Docker commands to execute in the terminal."
|
20 |
+
)
|
21 |
+
|
22 |
+
iface.launch()
|