|
import streamlit as st |
|
import subprocess |
|
|
|
|
|
st.set_page_config(page_title="Terminal Command Executor", layout="centered") |
|
|
|
|
|
st.title("🖥️ Simple Terminal Emulator") |
|
|
|
|
|
st.write("Enter a command and see the result below. This works just like your terminal!") |
|
|
|
|
|
command = st.text_input("Enter terminal command", placeholder="e.g., ls, pwd, echo 'Hello World'") |
|
|
|
|
|
if st.button("Run Command"): |
|
if command: |
|
try: |
|
|
|
result = subprocess.run(command, shell=True, capture_output=True, text=True) |
|
|
|
|
|
if result.stdout: |
|
st.subheader("Output:") |
|
st.code(result.stdout) |
|
|
|
|
|
if result.stderr: |
|
st.subheader("Error:") |
|
st.code(result.stderr) |
|
except Exception as e: |
|
st.error(f"An error occurred: {e}") |
|
else: |
|
st.warning("Please enter a command to run.") |
|
|