|
import gradio as gr |
|
import subprocess |
|
|
|
def run_command(command): |
|
try: |
|
result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True) |
|
return result.stdout |
|
except subprocess.CalledProcessError as e: |
|
return f"Error: {e.stderr}" |
|
|
|
def terminal_interface(command): |
|
return run_command(command) |
|
|
|
iface = gr.Interface( |
|
fn=terminal_interface, |
|
inputs=gr.Textbox(lines=2, placeholder="Enter your command here..."), |
|
outputs="text", |
|
title="Docker Command Runner", |
|
description="Enter Docker commands to execute in the terminal." |
|
) |
|
|
|
iface.launch() |
|
|