flask-bp is a comprehensive flask boilerplate for prototyping. It includes most common aspects of the projects such as Database migrations, resourceful routing, unit-testing and many more.
Swagger docs are supported for API. flask-apispec has been used to automatically generate swagger docs for APIs.
Swagger docs can be accessed at:
localhost:5000/apidocs
localhost:5000/apidocs-json
Automated unit testing base is configured using pytest with automatic coverage report.
Tests can be engaged using:
make test
Automated code linting is supported using Pylint
Linter can be engaged using:
make lint
A virtual environment should be used, e.g
virtualenv flaskbp-env
Activate the virtual environment and install the requirements:
source flaskbp-env/bin/activate
pip install -r requirements.txt
Run the flask-bp:
make start-dev
OR
flask run -h 0.0.0.0
Make sure you have installed docker and docker-compose.
- Create a
flaskbp
user with UID 9001 and change the ownership of the repo:
sudo useradd -u 9001 -m -d /home/flaskbp -s /bin/bash flaskbp
sudo chown -R 9001:9001 flask-bp
- Build Postgres Image using:
make -f docker/postgres/Makefile
- Build the dev server image using:
make -f docker/dev/Makefile
- After the build process completes, launch dev environment using:
docker-compose -f docker/dev/devenv-with-local-db.yml run --rm --service-ports dev-shell
To access the api server, you can access it on:
http://localhost:5000/api/v1/
There is one route defined which accepts a user information and return it back, it can be accessed:
http://localhost:5000/api/v1/user
It supports GET & POST method, GET for getting the user information from the database and POST to insert new user information to the database.
To access the auto generated swagger documentations:
http://localhost:5000/apidocs/
To export swagger docs in json format:
http://localhost:5000/apidocs-json/
To initialize database migrations
make install-db
To upgrade database schema
make upgrade-db
To clean project
make clean
To clean .pyc files
make clean-pyc
To run the tests
make test