File size: 1,286 Bytes
2e904fc
 
04774ba
 
 
2e904fc
 
 
 
 
 
 
 
 
 
 
 
04774ba
 
2e904fc
 
 
04774ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2e904fc
 
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
37
38
39
40
41
42
43
44
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()