|
import streamlit as st |
|
import subprocess |
|
|
|
|
|
st.set_page_config(page_title="Terminal Command Executor", layout="centered") |
|
|
|
|
|
st.title("๐ Run Terminal Commands Easily") |
|
|
|
|
|
st.markdown(""" |
|
### Simple and intuitive tool to execute terminal commands directly from this interface. |
|
Just enter a command, hit the button, and see the output below. |
|
""") |
|
|
|
|
|
command = st.text_input("๐ป Enter a terminal command", placeholder="e.g., ls, pwd, echo Hello World", max_chars=100) |
|
|
|
|
|
run_button = st.button("Run Command") |
|
|
|
|
|
if run_button and command: |
|
with st.spinner("Running command..."): |
|
try: |
|
|
|
result = subprocess.run(command, shell=True, capture_output=True, text=True) |
|
|
|
|
|
st.success("โ
Command executed successfully!") |
|
st.code(result.stdout, language="bash") |
|
|
|
|
|
if result.stderr: |
|
st.error(f"โ ๏ธ Error:\n{result.stderr}") |
|
except Exception as e: |
|
st.error(f"โ Failed to run command: {e}") |
|
else: |
|
if run_button: |
|
st.warning("โ ๏ธ Please enter a command.") |
|
|
|
|
|
st.markdown(""" |
|
<style> |
|
/* Hide footer */ |
|
footer {visibility: hidden;} |
|
|
|
/* Increase input box size and font */ |
|
.stTextInput input { |
|
font-size: 16px; |
|
height: 50px; |
|
width: 100%; |
|
padding: 10px; |
|
border-radius: 5px; |
|
border: 1px solid #3498db; |
|
background-color: #f0f4f8; |
|
color: #333; |
|
} |
|
|
|
/* Customize button */ |
|
.stButton button { |
|
background-color: #3498db; |
|
color: white; |
|
font-size: 16px; |
|
padding: 8px 16px; |
|
border-radius: 5px; |
|
border: none; |
|
} |
|
|
|
/* Set the success and warning messages to look cleaner */ |
|
.stAlert { |
|
font-size: 15px; |
|
} |
|
|
|
/* Customize code display */ |
|
.stCodeBlock { |
|
background-color: #2c3e50; |
|
color: #ecf0f1; |
|
padding: 10px; |
|
border-radius: 5px; |
|
} |
|
</style> |
|
""", unsafe_allow_html=True) |
|
|