Update app.py
Browse files
app.py
CHANGED
@@ -40,26 +40,24 @@ def run_command(command):
|
|
40 |
try:
|
41 |
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
42 |
if result.stdout:
|
43 |
-
st.subheader("Output:")
|
44 |
st.markdown(f'<div class="output">{result.stdout}</div>', unsafe_allow_html=True)
|
45 |
if result.stderr:
|
46 |
-
st.subheader("Error:")
|
47 |
st.markdown(f'<div class="error">{result.stderr}</div>', unsafe_allow_html=True)
|
48 |
except Exception as e:
|
49 |
st.error(f"An error occurred: {e}")
|
50 |
|
51 |
-
# Layout with columns
|
52 |
-
col1, col2 = st.columns([2, 1])
|
53 |
|
54 |
-
# Command history display in the
|
55 |
-
with
|
56 |
st.subheader("Command History")
|
57 |
for cmd in reversed(st.session_state.history):
|
58 |
if st.button(f"Run: {cmd}", key=cmd):
|
59 |
run_command(cmd)
|
60 |
|
61 |
-
# Command input and
|
62 |
-
with
|
63 |
command = st.text_area("Enter terminal command", placeholder="e.g., ls, pwd, echo 'Hello World'", height=100)
|
64 |
if st.button("Run Command"):
|
65 |
if command:
|
|
|
40 |
try:
|
41 |
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
42 |
if result.stdout:
|
|
|
43 |
st.markdown(f'<div class="output">{result.stdout}</div>', unsafe_allow_html=True)
|
44 |
if result.stderr:
|
|
|
45 |
st.markdown(f'<div class="error">{result.stderr}</div>', unsafe_allow_html=True)
|
46 |
except Exception as e:
|
47 |
st.error(f"An error occurred: {e}")
|
48 |
|
49 |
+
# Layout with three columns
|
50 |
+
col1, col2, col3 = st.columns([1, 2, 1])
|
51 |
|
52 |
+
# Command history display in the first column
|
53 |
+
with col1:
|
54 |
st.subheader("Command History")
|
55 |
for cmd in reversed(st.session_state.history):
|
56 |
if st.button(f"Run: {cmd}", key=cmd):
|
57 |
run_command(cmd)
|
58 |
|
59 |
+
# Command input and output in the second column
|
60 |
+
with col2:
|
61 |
command = st.text_area("Enter terminal command", placeholder="e.g., ls, pwd, echo 'Hello World'", height=100)
|
62 |
if st.button("Run Command"):
|
63 |
if command:
|