Skip to content

Commit 807ff34

Browse files
authored
Update README.md
1 parent 1198253 commit 807ff34

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

.learn/exercises/07-post_todo/README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ POST /todos
88
DELETE /todos
99
```
1010

11-
In order to build the `POST /todos` endpoint, we have to do something similar to what we did in the first endpoint with our GET method. Remember that each endpoint in a Flask API is represented by decorator `@app.route()` and a function `def my_function():` like this:
11+
In order to build the `POST /todos` endpoint, we have to do something similar to what we did in the first endpoint with our GET method. Remember that each endpoint in a Flask API is represented by decorator and a function, like this:
1212

1313
```python
1414
@app.route('/myroute', methods=['GET'])
1515
def hello_world():
16-
return 'Hello, World!'
16+
return 'Hello World!'
1717
```
1818

1919
In this case, we are not going to be expecting a `GET` request, but rather a `POST` request.
@@ -23,19 +23,13 @@ Also, we are expecting to receive the TODO that the client wants to add inside o
2323
```python
2424
from flask import request
2525

26-
# The request body is already JSON decoded, and it comes in the request.json variable
27-
print(request.json)
26+
# The request body is already JSON decoded, and it comes in the request.data variable
27+
print(request.data)
2828
```
2929

3030
## 📝 Instructions:
3131

32-
1. Remember to import `request` at the top of the file:
33-
34-
```python
35-
from flask import request
36-
```
37-
38-
2. Then, add the following endpoint to your app.py and test it:
32+
1. Add the following endpoint to your `app.py` and test it:
3933

4034
```python
4135
@app.route('/todos', methods=['POST'])
@@ -44,3 +38,11 @@ def add_new_todo():
4438
print("Incoming request with the following body", request_body)
4539
return 'Response for the POST todo'
4640
```
41+
42+
2. Remember to import `request` at the top of the file:
43+
44+
```python
45+
from flask import request
46+
```
47+
48+

0 commit comments

Comments
 (0)