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
Changed grammar and order of instructions based on class confusion and common questions we had when running into issues. This will eliminate further questions and lead to a better student experience.
Copy file name to clipboardExpand all lines: .learn/exercises/07-post_todo/README.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,15 +8,15 @@ POST /todos
8
8
DELETE /todos
9
9
```
10
10
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:
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 a function ( def my_function(): ) and a decorator ( @app.route() ) like this:
12
12
13
13
```python
14
-
@app.route('/blahblah', methods=['GET'])
14
+
@app.route('/myroute', methods=['GET'])
15
15
defhello_world():
16
16
return'Hello, World!'
17
17
```
18
18
19
-
Except in this case we are not going to be expecting a GET request.
19
+
In this case, we are not going to be expecting a `GET` request, but rather a `POST` 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
@@ -29,7 +29,13 @@ print(request.json)
29
29
30
30
## 📝 Instructions:
31
31
32
-
1. Add the folowing endpoint to your app.py and test it:
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 folowing endpoint to your app.py and test it:
33
39
34
40
```python
35
41
@app.route('/todos', methods=['POST'])
@@ -38,9 +44,3 @@ def add_new_todo():
38
44
print("Incoming request with the following body", request_body)
39
45
return'Response for the POST todo'
40
46
```
41
-
42
-
2. Remember to import request at the top of the file:
0 commit comments