Flask based API with PostgreSQL. Uses distroless docker image for app.
Using distroless python results in 72 MB image size versus 199 MB using 3.7-slim-buster.
Start app with PostgreSQL server:
docker-compose up
Get all phonebook entries:
curl -X GET localhost:5000/book/entries
Get entry by id:
curl -X GET localhost:5000/book/1
Add new entry:
curl -X POST \
-d '{"name":"boo", "phone":"+123"}' \
-H 'Content-Type: application/json' \
http://0.0.0.0:5000/book
Update existing entry:
curl -X PUT \
-d '{"name":"bob", "phone":"+432"}' \
-H 'Content-Type: application/json' \
http://0.0.0.0:5000/book/1
Delete entry:
curl -X DELETE http://0.0.0.0:5000/book/1
[1] https://hackersandslackers.com/flask-routes/
[2] https://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api