The steps below are should help you get set up on an Ubuntu system.
# install python 3 and dependencies
sudo apt update
sudo apt install -y \
build-essential \
libffi-dev \
libssl-dev \
hadolint \
python3 \
python-dev \
python3-pip \
python3-venv
# ensure python 3 is the default python version
cat >> ~/.bashrc << EOF
# python3 alias
alias python=python3
EOF
python --version
# install ruby for markdown linting
sudo apt install ruby
sudo gem install mdl
# clone repo
git clone [email protected]:robert-7/Full-Stack-Flask-Tutorial.git
cd Full-Stack-Flask-Tutorial
# set up virtualenv
python -m venv '.venv'
source .venv/bin/activate
# install requirements
pip install -r requirements.txt
# set up pre-commit so basic linting happens before every commit
pre-commit install
pre-commit run --all-files
Although the course instructs you to install MongoDB in your environment, I went down the route of installing docker first for WSL2 and then spinning up a container for this. Install following the installation commands here. Verify the install with:
which docker
Then to set up a MongoDB container, simply run:
docker compose build
docker compose up -d
To hop into the mongodb
container and view the imported documents, run:
# hop into our mongodb container, and begin a mongo shell with the UTA_Enrollment db selected
docker compose exec mongodb mongo UTA_Enrollment
db.getCollectionNames()
db.user.find()
To bring down the container, run docker-compose down -v
.
Unfortunately, for the time being, there are some steps that require Mongo Compass (running on Windows, for me as a WSL2 user). As of writing this, mongodb-compass-1.41.0 is the latest version.
To deactivate or reactivate your virtual environment, simply run:
deactivate # deactivates virtualenv
source .venv/bin/activate # reactivates virtualenv
Then spin up the Flask server separately (hoping to incorporate this into the docker compose file):
flask run
After you've installed Postman on your computer, import the Postman collection to have have the full API setup.