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. Here, we will use a Flask extension, Flask-Restless, developed completely from the point of view of building REST interfaces. It provides a simple generation of RESTful APIs for database models defined using SQLAlchemy. These generated APIs send and receive messages in the JSON format.
Getting ready
First, we need to install the Flask-Restless extension:
$ pip install Flask-Restless
We will build over our application from the SQL-based searching recipe of Chapter 4, Working with Views, to include a RESTful API interface.
Tip
It is advisable that you read Chapter 4, Working with Views, before moving ahead if the concepts of views and handlers are not clear.
How to do it…
Adding a RESTful API interface to a SQLAlchemy model is very easy with the use of Flask-Restless. First, we need to add the REST API manager provided by this extension...