From f796c4bfc6f2e3c3ea06a015814902e3e7e7b619 Mon Sep 17 00:00:00 2001 From: marcel-dempers Date: Fri, 12 Nov 2021 12:38:00 +1100 Subject: [PATCH] updates --- python/introduction/part-4.http/README.md | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/python/introduction/part-4.http/README.md b/python/introduction/part-4.http/README.md index 706363b..14ae74d 100644 --- a/python/introduction/part-4.http/README.md +++ b/python/introduction/part-4.http/README.md @@ -235,7 +235,7 @@ Notice the HTTP status code `200` indicating success. Routes allow us to have many endpoints, so we could have endpoints such as: ``` -/ --> which returns all customers +/all --> which returns all customers /get/ --> which returns one customer by CustomerID /add --> which adds or updates a customer ``` @@ -404,10 +404,7 @@ Note if we break the `json` format, we get a `400` status code
`400` = Bad Request
-Now we need to parse the request and validate it - -``` -``` +400 indicates a bad request, letting the client know they have to send the right formatted data. ## Docker @@ -420,22 +417,24 @@ FROM python:3.9.6-alpine3.13 as dev WORKDIR /work FROM dev as runtime -COPY ./src/ /app +WORKDIR /app +COPY requirements.txt /app/ +RUN pip install -r /app/requirements.txt -ENTRYPOINT [ "python", "/app/app.py" ] +COPY ./src/ /app +ENV FLASK_APP=app.py + +CMD flask run -h 0.0.0 -p 5000 ``` -Build and run our container. -Notice the `customers.json` file gets created if it does not exist. +Build our container. ``` cd python\introduction\part-4.http docker build . -t customer-app -docker run -p 5000:5000 customer-app - ``` Notice that we need to mount our `customers.json` file into the container.