Map HTTP Methods to Class Handlers
Implement get, post, put, and delete.
Verbs Become Methods
In Flask-RESTful each HTTP verb maps to a same-named method on your Resource. GET calls get, POST calls post.
Handle a GET
Define a get method to read data. Returning a dict sends it back as JSON automatically.
class Task(Resource):
def get(self, task_id):
return {"id": task_id}All lessons in this course
- Resource Classes and the Api Object
- Map HTTP Methods to Class Handlers
- Parse and Validate with reqparse
- Blueprint-Mounted REST Resources