hacked / app.py
luluhacker's picture
Update app.py
4026a06 verified
raw
history blame contribute delete
808 Bytes
import gradio as gr
import subprocess
def run_command(command):
try:
# Run the command and capture the output
result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
# Return the output or any error encountered
if result.returncode == 0:
return f"Output:\n{result.stdout}"
else:
return f"Error:\n{result.stderr}"
except Exception as e:
return str(e)
# Create a Gradio interface
iface = gr.Interface(fn=run_command,
inputs="text",
outputs="text",
title="Linux Command Runner",
description="Enter a Linux command to execute and see the output.")
# Launch the interface
iface.launch()