Creating a SQLAlchemy-independent REST API
In the previous recipe, Creating an extension-based REST interface, we saw how to create a REST API interface using an extension that was dependent on SQLAlchemy. Now, we will use an extension called Flask-Restful, which is written over Flask pluggable views and is independent of ORM.
Getting ready
First, we will start with the installation of the extension:
$ pip install Flask-Restful
We will modify the catalog application from the previous recipe to add a REST interface using this extension.
How to do it…
As always, we will start with changes to our application's configuration, which will look something like the following lines of code:
from flask.ext.restful import Api api = Api(app)
Here, app
is our Flask application object/instance.
Next, we will create our API inside the views.py
file. Here, we will just try to understand how to lay out the skeleton of the API. Actual methods and handlers will be covered in the A complete REST API example recipe...