This commit is contained in:
marcel-dempers 2021-11-18 08:57:39 +11:00
parent f796c4bfc6
commit d47976ffa8
5 changed files with 12 additions and 9 deletions

View File

@ -185,7 +185,7 @@ our application and needs grow. Best is to use a `requirements.txt` file.
Let's create a `requirements.txt` file:
```
Flask == 2.0.1
Flask == 2.0.2
```
We can install our dependencies using:
@ -418,10 +418,10 @@ WORKDIR /work
FROM dev as runtime
WORKDIR /app
COPY requirements.txt /app/
COPY ./src/requirements.txt /app/
RUN pip install -r /app/requirements.txt
COPY ./src/ /app
COPY ./src/app.py /app/app.py
ENV FLASK_APP=app.py
CMD flask run -h 0.0.0 -p 5000

View File

@ -4,10 +4,11 @@ WORKDIR /work
FROM dev as runtime
WORKDIR /app
COPY requirements.txt /app/
COPY ./src/requirements.txt /app/
RUN pip install -r /app/requirements.txt
COPY ./src/ /app
COPY ./src/app.py /app/app.py
ENV FLASK_APP=app.py
CMD flask run -h 0.0.0 -p 5000

View File

@ -1 +0,0 @@
Flask == 2.0.1

View File

@ -24,10 +24,11 @@ def getCustomers():
def getCustomer(customerID):
customers = getCustomers()
if customerID in customers:
return customers[customerID]
else:
return {}
else:
return {}
def updateCustomers(customers):
with open(dataPath, 'w', newline='') as customerFile:
@ -44,6 +45,7 @@ def get_customers():
@app.route("/get/<string:customerID>", methods=['GET'])
def get_customer(customerID):
customer = getCustomer(customerID)
if customer == {}:
return {}, 404
else:
@ -59,7 +61,7 @@ def add_customer():
return "firstName required", 400
if "lastName" not in jsonData:
return "lastName required", 400
customers = getCustomers()
customers[jsonData["customerID"]] = Customer( jsonData["customerID"], jsonData["firstName"], jsonData["lastName"]).__dict__
updateCustomers(customers)

View File

@ -0,0 +1 @@
Flask == 2.0.2