This example is made thanks Realpython tutorial.
On ubuntu
sudo apt install vitualenv
virtualenv --python=python3 venv
source venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install flake8 black
pip install pytest pytest-cov
pip install flask
pip install connexion[swagger-ui]
Run black to help to fix linter issues. Warning must be done is separate commits for QA.
black rest_example
black tests
Stop the build if Python syntax errors or undefined names
flake8 rest_example --exclude rest_example/__init__.py --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 tests --count --select=E9,F63,F7,F82 --show-source --statistics
Treats all errors as warnings
flake8 rest_example --exclude rest_example/__init__.py --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
flake8 tests --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
pytest --cov-config=.coveragerc --cov=rest_example --cov-report=html --cov-report=term --log-cli-level=6 tests
xdg-open htmlcov/index.html
python rest_example/app.py
To check people:
xdg-open http://localhost:5000/api/people
Or to consult swagger ui:
xdg-open http://localhost:5000/api/ui
python3 setup.py sdist
pip install path/to/file.tar.gz