Creating an extension-based REST interface
In the previous recipe, Creating a class-based REST interface, we saw how to create a REST interface using pluggable views. In this recipe, we will use an extension called Flask- RESTful, which is written over the same pluggable views we used in the previous recipe, but which handles a lot of nuances by itself to allow us developers to focus on actual API development. It is also independent of object-relational mapping (ORM), so there are no strings attached to the ORM we may want to use.
Getting ready
First, we will begin with the installation of the extension:
$ pip install flask-restful
We will modify the catalog application from the last recipe to add a REST interface using this extension.
How to do it…
As always, start with changes to the application’s configuration in my_app/__init__.py
, which will look something like the following lines of code:
from flask_restful import Api api = Api(app)
Here...