Spaces:
Paused
Paused
Update main.py
Browse files
main.py
CHANGED
|
@@ -1,32 +1,25 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import os
|
| 3 |
import subprocess
|
| 4 |
|
| 5 |
-
def
|
| 6 |
-
output = ""
|
| 7 |
try:
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
#subprocess.run(["docker-compose", "up", "-d"], check=True)
|
| 13 |
-
#output += "Started Milvus server\n"
|
| 14 |
-
except Exception as e:
|
| 15 |
-
output += str(e)
|
| 16 |
-
return output
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
-
iface = gr.Interface(
|
| 24 |
-
fn=[install_server, list_files],
|
| 25 |
-
inputs=None,
|
| 26 |
-
outputs=["text", "text"],
|
| 27 |
-
title="Milvus Server Installation"
|
| 28 |
-
)
|
| 29 |
-
iface.launch(server_name="0.0.0.0", server_port=7860)
|
| 30 |
-
|
| 31 |
-
if __name__ == "__main__":
|
| 32 |
-
run()
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
import subprocess
|
| 3 |
|
| 4 |
+
def run_command(command):
|
|
|
|
| 5 |
try:
|
| 6 |
+
result = subprocess.check_output(command, shell=True, text=True)
|
| 7 |
+
return result
|
| 8 |
+
except subprocess.CalledProcessError as e:
|
| 9 |
+
return f"Error: {e}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
iface = gr.Interface(
|
| 12 |
+
fn=run_command,
|
| 13 |
+
inputs="text",
|
| 14 |
+
outputs="text",
|
| 15 |
+
live=True,
|
| 16 |
+
title="Command Output Viewer",
|
| 17 |
+
description="Enter a command and view its output.",
|
| 18 |
+
examples=[
|
| 19 |
+
["ls"],
|
| 20 |
+
["pwd"],
|
| 21 |
+
["echo 'Hello, Gradio!'"]
|
| 22 |
+
]
|
| 23 |
+
)
|
| 24 |
|
| 25 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|