luluhacker commited on
Commit
584a875
·
verified ·
1 Parent(s): 21fe7c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -4
app.py CHANGED
@@ -1,7 +1,25 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import subprocess
3
 
4
+ def run_command(command):
5
+ try:
6
+ # Run the command and capture the output
7
+ result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
8
+
9
+ # Return the output or any error encountered
10
+ if result.returncode == 0:
11
+ return f"Output:\n{result.stdout}"
12
+ else:
13
+ return f"Error:\n{result.stderr}"
14
+ except Exception as e:
15
+ return str(e)
16
 
17
+ # Create a Gradio interface
18
+ iface = gr.Interface(fn=run_command,
19
+ inputs="text",
20
+ outputs="text",
21
+ title="Linux Command Runner",
22
+ description="Enter a Linux command to execute and see the output.")
23
+
24
+ # Launch the interface
25
+ iface.launch()