skanaujiya commited on
Commit
eec2447
ยท
verified ยท
1 Parent(s): 2510953

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +69 -65
app.py CHANGED
@@ -1,79 +1,83 @@
1
  import streamlit as st
2
  import subprocess
3
 
4
- # Sidebar for user instructions and input
5
- st.sidebar.title("Terminal Command Runner")
6
- st.sidebar.write("Enter a terminal command below, and click the **Run Command** button to execute it.")
7
 
8
- # Main page layout
9
- st.title("๐Ÿš€ Terminal Command Executor")
 
 
10
  st.markdown("""
11
- This tool allows you to run terminal commands directly from the web interface.
12
- Enter a command in the input field, and the output will be displayed below.
13
  """)
14
 
15
- # Create a larger input field with enhanced visibility
16
- command = st.text_input("๐Ÿ’ป Enter a terminal command:", placeholder="e.g., ls, pwd, echo Hello World")
17
 
18
- # Create a button to execute the command
19
- if st.button("Run Command"):
20
- if command:
21
- with st.spinner("Running the command..."):
22
- try:
23
- # Execute the terminal command and capture the output
24
- result = subprocess.run(command, shell=True, capture_output=True, text=True)
25
-
26
- # Display the output in the Streamlit app
27
- st.success("Command executed successfully!")
28
- st.subheader("๐Ÿ“œ Command Output:")
29
- st.code(result.stdout, language="bash")
30
-
31
- # Display errors, if any
32
- if result.stderr:
33
- st.error(f"โš ๏ธ Error:\n{result.stderr}")
34
- except Exception as e:
35
- st.error(f"โŒ Error running command: {e}")
36
- else:
37
- st.warning("โš ๏ธ Please enter a command to run.")
38
 
39
- # Display additional tips in the sidebar
40
- st.sidebar.header("Quick Tips")
41
- st.sidebar.write("""
42
- - To list files: `ls`
43
- - To show current directory: `pwd`
44
- - To display system info: `uname -a`
45
- - To print something: `echo "Hello"`
46
- """)
 
 
 
 
 
 
 
 
 
 
 
47
 
48
- # A footer for better UI and personalized touch
49
  st.markdown("""
50
  <style>
51
- footer {visibility: hidden;}
52
- .css-18e3th9 {background-color: #34495e;}
53
- h1 {color: #3498db;}
54
- .stTextInput input {
55
- height: 50px; /* Increase input box height */
56
- font-size: 18px; /* Increase font size */
57
- border: 1px solid #2980b9;
58
- background-color: #ecf0f1;
59
- color: black; /* Set text color to black for visibility */
60
- }
61
- .stButton button {
62
- background-color: #27ae60;
63
- color: white;
64
- font-size: 16px;
65
- }
66
- .stMarkdown h2, .stMarkdown h3 {
67
- color: #2ecc71;
68
- }
69
- .stTextArea textarea {
70
- border-color: #3498db;
71
- }
72
- .css-qbe2hs {
73
- color: #f1c40f;
74
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  </style>
76
  """, unsafe_allow_html=True)
77
-
78
- # Custom footer text for a user-friendly experience
79
- st.markdown("๐Ÿ’ก **Tip**: Use simple commands and see the output instantly. Happy hacking!")
 
1
  import streamlit as st
2
  import subprocess
3
 
4
+ # Set the page layout to wide mode for a cleaner look
5
+ st.set_page_config(page_title="Terminal Command Executor", layout="centered")
 
6
 
7
+ # Main title with emojis for visual appeal
8
+ st.title("๐Ÿš€ Run Terminal Commands Easily")
9
+
10
+ # Brief description to guide the user
11
  st.markdown("""
12
+ ### Simple and intuitive tool to execute terminal commands directly from this interface.
13
+ Just enter a command, hit the button, and see the output below.
14
  """)
15
 
16
+ # Create a larger and clearer input field with a placeholder
17
+ command = st.text_input("๐Ÿ’ป Enter a terminal command", placeholder="e.g., ls, pwd, echo Hello World", max_chars=100)
18
 
19
+ # Button to run the command
20
+ run_button = st.button("Run Command")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
+ # Display the output when the command is executed
23
+ if run_button and command:
24
+ with st.spinner("Running command..."):
25
+ try:
26
+ # Run the terminal command and capture output
27
+ result = subprocess.run(command, shell=True, capture_output=True, text=True)
28
+
29
+ # Display success message and output
30
+ st.success("โœ… Command executed successfully!")
31
+ st.code(result.stdout, language="bash")
32
+
33
+ # Display any errors in red
34
+ if result.stderr:
35
+ st.error(f"โš ๏ธ Error:\n{result.stderr}")
36
+ except Exception as e:
37
+ st.error(f"โŒ Failed to run command: {e}")
38
+ else:
39
+ if run_button:
40
+ st.warning("โš ๏ธ Please enter a command.")
41
 
42
+ # Custom CSS to simplify and style the UI
43
  st.markdown("""
44
  <style>
45
+ /* Hide footer */
46
+ footer {visibility: hidden;}
47
+
48
+ /* Increase input box size and font */
49
+ .stTextInput input {
50
+ font-size: 16px;
51
+ height: 50px;
52
+ width: 100%;
53
+ padding: 10px;
54
+ border-radius: 5px;
55
+ border: 1px solid #3498db;
56
+ background-color: #f0f4f8;
57
+ color: #333;
58
+ }
59
+
60
+ /* Customize button */
61
+ .stButton button {
62
+ background-color: #3498db;
63
+ color: white;
64
+ font-size: 16px;
65
+ padding: 8px 16px;
66
+ border-radius: 5px;
67
+ border: none;
68
+ }
69
+
70
+ /* Set the success and warning messages to look cleaner */
71
+ .stAlert {
72
+ font-size: 15px;
73
+ }
74
+
75
+ /* Customize code display */
76
+ .stCodeBlock {
77
+ background-color: #2c3e50;
78
+ color: #ecf0f1;
79
+ padding: 10px;
80
+ border-radius: 5px;
81
+ }
82
  </style>
83
  """, unsafe_allow_html=True)