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

Getting ready

We will do this with the help of Redis, which can be installed using the following command:

    $ pip3 install redis 

Make sure that you run the Redis server for the connection to happen. To install and run a Redis server, refer to http://redis.io/topics/quickstart.

Then, we need to have the connection open to Redis. This can be done by adding the following lines of code to my_app/__init__.py:

from redis import Redis 
redis = Redis() 

We can do this in our application file, where we will define the app, or in the views file, where we will use it. It is preferred that you do this in the application file because then, the connection will be open throughout the application, and the redis object can be used by just importing it where ...

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