Skip to content

bcochofel/py_dummy_service

Repository files navigation

py_dummy_service

codecov docker pulls docker image size pre-commit badge Conventional commits badge Keep a Changelog v1.1.0 badge MIT License Badge

Python Flask Dummy Service

Install requirements

python3 -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install -r requirements

additional requirements for running tests

pip install black pytest coverage gunicorn

Run locally

export FLASK_ENV=development
export FLASK_APP=py_dummy_service
flask run

valid values for env:

  • development
  • testing
  • production (default)

you can check available routes using:

export FLASK_APP=py_dummy_service
flask routes

You can use the /api/v1/<path> to simulate CRUD API endpoints.

You also have two endpoints that can help with simulations:

  • /api/v1/headers (returns request headers)
  • /api/v1/status/<status> (returns <status>)

You can also use /be to simulate communication to a backend. The backend url can be set using:

export BACKEND_URL="http://localhost:5000"

you can then use:

  • /be/status/<status>
  • /be/<path>

POST Form Data

curl -d "param1=value1&param2=value2" -X POST  localhost:5000/api/v1/backend

POST JSON

curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" -X POST localhost:5000/api/v1/backend

Run tests and code coverage

make test
make report

Run on Docker

make build
make run
make kill

Open Tracing

To send traces to Jaeger set the JAEGER_HOST environment variable.

pre-commit hooks

Read the pre-commit hooks document for more info.

git-chglog

Read the git-chglog document for more info.