BashSL / app.py
mmty's picture
Update app.py
04774ba verified
Raw History Blame Contribute Delete
1.29 kB
import streamlit as st
import subprocess
import matplotlib.pyplot as plt
import numpy as np
import time
def run_bash_command(command):
"""Run bash command and display output"""
st.info(f"Running command: `{command}`")
result = subprocess.run(command, shell=True, capture_output=True, text=True)
if result.returncode == 0:
st.info(result.stdout)
else:
st.error(result.stderr)
def main():
st.title("Bash Command Executor")
st.write("Enter your bash command:")
command = st.text_input("")
if st.button("Run"):
run_bash_command(command)
# Add a feature to plot random data points
st.write("Plotting random data points:")
max_x = 5
max_rand = 10
x = np.arange(0, max_x)
fig, ax = plt.subplots()
ax.set_ylim(0, max_rand)
ax.set_xlim(0, max_x)
ax.set_title("Random Data Points")
ax.set_xlabel("X")
ax.set_ylabel("Y")
for i in range(max_x):
y = np.random.randint(0, max_rand)
ax.plot(i, y, 'bo')
st.pyplot(fig)
time.sleep(0.5)
# Add a badge to star the GitHub project
st.write("[![Star](https://img.shields.io/github/stars/username/repo.svg?logo=github&style=social)](https://github.com/username/repo)")
if __name__ == "__main__":
main()