Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,20 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess
|
| 3 |
-
import piper
|
| 4 |
|
| 5 |
-
def
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
return
|
| 12 |
-
else:
|
| 13 |
-
return None
|
| 14 |
|
| 15 |
iface = gr.Interface(
|
| 16 |
-
fn=
|
| 17 |
inputs='text',
|
| 18 |
-
outputs='
|
|
|
|
|
|
|
| 19 |
)
|
| 20 |
|
| 21 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess
|
|
|
|
| 3 |
|
| 4 |
+
def run_command(command):
|
| 5 |
+
try:
|
| 6 |
+
# Running the command and capturing the output
|
| 7 |
+
result = subprocess.run(command, shell=True, text=True, capture_output=True, check=True)
|
| 8 |
+
return result.stdout
|
| 9 |
+
except subprocess.CalledProcessError as e:
|
| 10 |
+
return e.stderr
|
|
|
|
|
|
|
| 11 |
|
| 12 |
iface = gr.Interface(
|
| 13 |
+
fn=run_command,
|
| 14 |
inputs='text',
|
| 15 |
+
outputs='text',
|
| 16 |
+
title="CLI Interface",
|
| 17 |
+
description="Enter your command and see the output."
|
| 18 |
)
|
| 19 |
|
| 20 |
iface.launch()
|