init
Browse files
app.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import subprocess
|
3 |
+
|
4 |
+
# Streamlit UI layout
|
5 |
+
st.title("Run Terminal Commands")
|
6 |
+
|
7 |
+
# Create a text input field to enter the command
|
8 |
+
command = st.text_input("Enter terminal command:")
|
9 |
+
|
10 |
+
# Create a button to execute the command
|
11 |
+
if st.button("Run Command"):
|
12 |
+
if command:
|
13 |
+
try:
|
14 |
+
# Execute the terminal command and capture the output
|
15 |
+
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
16 |
+
# Display the output in the Streamlit app
|
17 |
+
st.subheader("Command Output:")
|
18 |
+
st.code(result.stdout)
|
19 |
+
# Display errors, if any
|
20 |
+
if result.stderr:
|
21 |
+
st.error(result.stderr)
|
22 |
+
except Exception as e:
|
23 |
+
st.error(f"Error running command: {e}")
|
24 |
+
else:
|
25 |
+
st.warning("Please enter a command to run.")
|
26 |
+
|
27 |
+
# A footer for better UI
|
28 |
+
st.markdown("""
|
29 |
+
<style>
|
30 |
+
footer {
|
31 |
+
visibility: hidden;
|
32 |
+
}
|
33 |
+
.css-18e3th9 {
|
34 |
+
background-color: #2c3e50;
|
35 |
+
}
|
36 |
+
h1 {
|
37 |
+
color: #3498db;
|
38 |
+
}
|
39 |
+
.stTextInput input {
|
40 |
+
border: 1px solid #3498db;
|
41 |
+
}
|
42 |
+
.stButton button {
|
43 |
+
background-color: #3498db;
|
44 |
+
color: white;
|
45 |
+
}
|
46 |
+
.stTextArea textarea {
|
47 |
+
border-color: #3498db;
|
48 |
+
}
|
49 |
+
</style>
|
50 |
+
""", unsafe_allow_html=True)
|