You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .learn/exercises/07-post_todo/README.md
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -8,23 +8,23 @@ POST /todos
8
8
DELETE /todos
9
9
```
10
10
11
-
In order to build the `POST /todos` have do something similar that we did on the first endpoint. Remember that each endpoint in a Flask API is represented by a function and a decorator like this:
11
+
In order to build the `POST /todos`we have to do something similar to what we did in the first endpoint. Remember that each endpoint in a Flask API is represented by a function and a decorator like this:
12
12
13
13
```python
14
-
@app.route('/blabla', methods=['GET'])
14
+
@app.route('/blahblah', methods=['GET'])
15
15
defhello_world():
16
16
return'Hello, World!'
17
17
```
18
18
19
-
Only in this case, we are not going to be expecting a GET request.
19
+
Except in this case we are not going to be expecting a GET request.
20
20
21
21
Also, we are expecting to receive the TODO that the client wants to add inside of the request body.
22
22
23
23
```python
24
24
from flask import request
25
25
26
-
# the request body is already json decoded and it comes in the request.data variable
27
-
print(request.data)
26
+
# the request body is already json decoded and it comes in the request.json variable
27
+
print(request.json)
28
28
```
29
29
30
30
## 📝 Instructions:
@@ -34,7 +34,7 @@ print(request.data)
34
34
```python
35
35
@app.route('/todos', methods=['POST'])
36
36
defadd_new_todo():
37
-
request_body = request.data
37
+
request_body = request.json
38
38
print("Incoming request with the following body", request_body)
0 commit comments