Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,13 @@
|
|
| 1 |
import subprocess
|
| 2 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
def run_command(cmd):
|
|
@@ -21,11 +29,16 @@ def run_command(cmd):
|
|
| 21 |
except Exception as e:
|
| 22 |
return f"Error executing command: {str(e)}"
|
| 23 |
|
|
|
|
| 24 |
with gr.Blocks(title="Gradio Terminal") as demo:
|
| 25 |
gr.Markdown("## 🛠️ Gradio Terminal Executor")
|
| 26 |
|
| 27 |
with gr.Row():
|
| 28 |
-
cmd_input = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
run_btn = gr.Button("Run", scale=1)
|
| 30 |
|
| 31 |
output_box = gr.Code(label="Terminal Output", language="shell", interactive=False)
|
|
@@ -34,5 +47,4 @@ with gr.Blocks(title="Gradio Terminal") as demo:
|
|
| 34 |
cmd_input.submit(fn=run_command, inputs=cmd_input, outputs=output_box)
|
| 35 |
|
| 36 |
if __name__ == "__main__":
|
| 37 |
-
|
| 38 |
-
demo.launch(ssr_mode=False, server_name="0.0.0.0", server_port=7860, share=True)
|
|
|
|
| 1 |
import subprocess
|
| 2 |
import os
|
| 3 |
+
import shutil
|
| 4 |
+
|
| 5 |
+
# 1. Install OpenClaw automatically at startup if it isn't installed yet
|
| 6 |
+
if not shutil.which("openclaw"):
|
| 7 |
+
print("Installing OpenClaw globally...")
|
| 8 |
+
subprocess.run(["npm", "install", "-g", "openclaw@latest"], check=True)
|
| 9 |
+
print("OpenClaw installed successfully!")
|
| 10 |
+
|
| 11 |
import gradio as gr
|
| 12 |
|
| 13 |
def run_command(cmd):
|
|
|
|
| 29 |
except Exception as e:
|
| 30 |
return f"Error executing command: {str(e)}"
|
| 31 |
|
| 32 |
+
# 2. Launch Gradio interface
|
| 33 |
with gr.Blocks(title="Gradio Terminal") as demo:
|
| 34 |
gr.Markdown("## 🛠️ Gradio Terminal Executor")
|
| 35 |
|
| 36 |
with gr.Row():
|
| 37 |
+
cmd_input = gr.Textbox(
|
| 38 |
+
placeholder="Type bash command here (e.g., openclaw --version)...",
|
| 39 |
+
label="Command",
|
| 40 |
+
scale=4
|
| 41 |
+
)
|
| 42 |
run_btn = gr.Button("Run", scale=1)
|
| 43 |
|
| 44 |
output_box = gr.Code(label="Terminal Output", language="shell", interactive=False)
|
|
|
|
| 47 |
cmd_input.submit(fn=run_command, inputs=cmd_input, outputs=output_box)
|
| 48 |
|
| 49 |
if __name__ == "__main__":
|
| 50 |
+
demo.launch(ssr_mode=False, server_name="0.0.0.0", server_port=7860)
|
|
|