Reader small image

You're reading from  Practical Python Programming for IoT

Product typeBook
Published inNov 2020
Reading LevelIntermediate
PublisherPackt
ISBN-139781838982461
Edition1st Edition
Languages
Right arrow

Flask and Flask-RESTful API instance variables

In the following, on line (4), we create an instance of our core Flask app and assign it to the app variable. The parameter is the name of our Flask application, and it's a common convention to use __name__ for the root Flask app (we only have a root Flask app in our example). Anytime we need to work with the core Flask framework, we will use the app variable:

app = Flask(__name__) # Core Flask app.            # (4)
api = Api(app) # Flask-RESTful extension wrapper # (5)

On line (5), we wrap the core Flask app with the Flask-RESTful extension and assign it to the api variable, and as we will see shortly, we use this variable anytime we are working with the Flask-RESTful extension. Following our app and api variables, we define additional global variables.

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Practical Python Programming for IoT
Published in: Nov 2020Publisher: PacktISBN-13: 9781838982461