File size: 539 Bytes
66f8fc1
5ce139d
 
e8f2900
5ce139d
e8f2900
 
 
 
5ce139d
e8f2900
 
 
 
 
 
 
 
 
 
 
 
 
66f8fc1
e8f2900
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import gradio as gr
import subprocess

def run_command(command):
    try:
        result = subprocess.check_output(command, shell=True, text=True)
        return result
    except subprocess.CalledProcessError as e:
        return f"Error: {e}"

iface = gr.Interface(
    fn=run_command,
    inputs="text",
    outputs="text",
    live=True,
    title="Command Output Viewer",
    description="Enter a command and view its output.",
    examples=[
        ["ls"],
        ["pwd"],
        ["echo 'Hello, Gradio!'"]
    ]
)

iface.launch()