File size: 504 Bytes
72428b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
import subprocess

def run_bash_command(command):
    try:
        result = subprocess.run(command, shell=True, capture_output=True, text=True)
        output = result.stdout if result.stdout else result.stderr
        return output
    except Exception as e:
        return str(e)

interface = gr.Interface(
    fn=run_bash_command,
    inputs="text",
    outputs="text",
    title="Terminal Emulator",
    description="Enter bash commands and see the output."
)

interface.launch()