Skip to content

Instantly share code, notes, and snippets.

@christophergandrud
Last active July 20, 2023 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christophergandrud/8f467beaf72a0ae1f417c3e8364c0039 to your computer and use it in GitHub Desktop.
Save christophergandrud/8f467beaf72a0ae1f417c3e8364c0039 to your computer and use it in GitHub Desktop.
Bash script to create an empty Streamlit app

Bash script to create a skeleton Streamlit app

To run the script from the command line use:

curl -s https://gist.githubusercontent.com/christophergandrud/8f467beaf72a0ae1f417c3e8364c0039/raw/774b35818c72575e42aa703f472ee43cbc9d4c79/streamlit-build.sh -o script.sh && chmod +x script.sh && ./script.sh && rm script.sh
#!/bin/bash
# Prompt the user for the app name
read -p "Enter the name of your Streamlit app: " app_name
# Create the directory
mkdir $app_name
# Navigate to the new directory
cd $app_name
# Create the source directory
mkdir src
# Create the main app file
touch app.py
# Output a sample message to the main app file
echo "import streamlit as st
def main():
st.title('Welcome to $app_name')
if __name__ == '__main__':
main()" > app.py
# Provide execution permissions to the main app file
chmod +x app.py
# Create the README file
touch README.md
# Output instructions to the README file
echo "# $app_name
## Instructions for Building the Streamlit App
1. Make sure you have Python installed on your system.
2. Install the required dependencies by running the following command:
\`\`\`bash
pip install streamlit
\`\`\`
3. Navigate to the project directory:
\`\`\`bash
cd $app_name
\`\`\`
4. Run the following command to build the app:
\`\`\`bash
streamlit run app.py
\`\`\`
5. Open your web browser and visit <http://localhost:8501> to see the app in action.
Feel free to modify the \`app.py\` file and add your own functionality to the Streamlit app.
Enjoy building your Streamlit app!" > README.md
# Display a success message
echo "Streamlit app structure created successfully in the directory: $app_name"
echo "Please us a virtual environment for your Streamlit app."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment