Working with resourceful routing on top of Flask pluggable views
Flask-RESTful uses resources built on top of Flask pluggable views as the main building block for a RESTful API. We just need to create a subclass of the flask_restful.Resource
class and declare the methods for each supported HTTP verb. A subclass of flask_restful.Resource
represents a RESTful resource and therefore, we will have to declare one class to represent the collection of messages and another one to represent the message resource.
First, we will create a Message
class that we will use to represent the message resource. Open the previously created api/api.py
file and add the following lines. The code file for the sample is included in the restful_python_chapter_05_01
folder, ...
Get Building RESTful Python Web Services now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.