ruslanmv commited on
Commit
e8f2900
1 Parent(s): eeba91f

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +19 -26
main.py CHANGED
@@ -1,32 +1,25 @@
1
  import gradio as gr
2
- import os
3
  import subprocess
4
 
5
- def install_server():
6
- output = ""
7
  try:
8
- os.mkdir("milvus_compose")
9
- output += "Created directory 'milvus_compose'\n"
10
- subprocess.run(["wget", "https://github.com/milvus-io/milvus/releases/download/v2.3.0-beta/milvus-standalone-docker-compose.yml", "-O", "milvus_compose/docker-compose.yml"], check=True)
11
- #output += "Downloaded 'docker-compose.yml'\n"
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
- def list_files():
19
- files = os.listdir('.')
20
- return files
 
 
 
 
 
 
 
 
 
 
21
 
22
- def run():
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()