File size: 1,155 Bytes
8b49023
 
 
720e97a
eec2447
8b49023
720e97a
 
eec2447
720e97a
 
475d256
720e97a
 
8b49023
eec2447
720e97a
 
eec2447
720e97a
eec2447
 
720e97a
 
 
 
eec2447
720e97a
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import streamlit as st
import subprocess

# Set the page layout to wide mode for better spacing
st.set_page_config(page_title="Terminal Command Executor", layout="centered")

# Main title
st.title("🖥️ Simple Terminal Emulator")

# Instruction text
st.write("Enter a command and see the result below. This works just like your terminal!")

# Input field for terminal command
command = st.text_input("Enter terminal command", placeholder="e.g., ls, pwd, echo 'Hello World'")

# Button to run the command
if st.button("Run Command"):
    if command:
        try:
            # Execute the terminal command and capture the output
            result = subprocess.run(command, shell=True, capture_output=True, text=True)

            # Show the output
            if result.stdout:
                st.subheader("Output:")
                st.code(result.stdout)

            # Show any errors if they occur
            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.")