The flask-restx-boilerplate allows you to create fast a Flask API application.
Besides that there is an How-To for beginners in the Wiki, which explains step by step how to add a new API Endpoint
The code is mainly based on the following repo cosmic-byte/flask-restplus-boilerplate and a little bit from antkahn/flask-api-starter-kit
There are the following differences in the repositories aboth:
- The tutorials are a little bit outdated and work no longer correctly
- The package versions are outdated and no longer match the tutorial
- This repository combines the best of both (for my understanding)
- Use Flask CLI instead of manager (nativ)
- Use no makefiles (All os friendly)
-
clone this repository
git clone https://github.com/Ezak91/flask-restx-boilerplate
-
change to directory
cd flask-restx-boilerplate
-
creat venv
# windows py -3 -m venv .venv # on linux/mac python3 -m venv .venv
-
activate venv
# windows .venv\scripts\activate # on linux/mac source .venv/bin/activate
-
install requirements
# for developing pip install -r requirements-dev.txt # only run pip install -r requirements.txt
-
setup flask application
# bash (linux, mac) export FLASK_APP=run # bash (windows) set FLASK_APP=run # powershell (windows) $env:FLASK_APP = "run"
-
setup database
flask db init flask db migrate -m "Initial migration." flask db upgrade
-
setup flask application
# bash (linux, mac) export FLASK_APP=run # bash (windows) set FLASK_APP=run # powershell (windows) $env:FLASK_APP = "run"
-
run flask application
flask run
-
Now you can open the following url in your browser to see the swagger ui page
http://127.0.0.1:5000