Rest API & Flask tutorial app. See readme below.
917
Rest API tutorial app from here: https://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask
Slightly modified for Python 3 (just modify a type check for unicode to use str instead) and the authentication parts skipped. The app runs non-root in the container so it works out of the box with OpenShift.
API endpoint path: someserver:5000/todo/api/v1.0/tasks
Example calls when running in docker on localhost:
Add entry:
curl -i -H "Content-Type: application/json" -X POST -d '{"title":"Read a paper","description":"Read a paper you must"}' http://localhost:5000/todo/api/v1.0/tasks
Modify entries (entry ID at the end of URL):
curl -i -H "Content-Type: application/json" -X PUT -d '{"title":"Read a paper"}' http://localhost:5000/todo/api/v1.0/tasks/5
curl -i -H "Content-Type: application/json" -X PUT -d '{"description":"TASK NUMBER FIVE!"}' http://localhost:5000/todo/api/v1.0/tasks/5
curl -i -H "Content-Type: application/json" -X PUT -d '{"done":true}' http://localhost:5000/todo/api/v1.0/tasks/5
Delete entry:
curl -i -H "Content-Type: application/json" -X DELETE http://localhost:5000/todo/api/v1.0/tasks/2
Dockerfile:
FROM python:3.8-alpine3.11
RUN pip install flask
EXPOSE 5000
USER 2001:2001
COPY app.py /app.py
CMD ["python3", "/app.py"]
Content type
Image
Digest
Size
39 MB
Last updated
over 6 years ago
docker pull l4rs71/todo-api