Skip to Content
Flask Framework Cookbook - Second Edition
book

Flask Framework Cookbook - Second Edition

by Shalabh Aggarwal
July 2019
Beginner to intermediate
302 pages
9h 38m
English
Packt Publishing
Content preview from Flask Framework Cookbook - Second Edition

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, app is our Flask application object/instance.

Next, create the 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 Creating a complete RESTful API recipe:

from flask_restful import Resource from my_app import api class ProductApi(Resource): def get(self, id=None): # Return product data return 'This is a GET response' def post(self): # Create a new product return 'This is a POST response' def put(self, id): # Update the product ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Writing a Web Application with Flask

Writing a Web Application with Flask

Doug Farrell
Mastering Flask

Mastering Flask

Jack Stouffer

Publisher Resources

ISBN: 9781789951295Supplemental Content