Complete the code to import the Redis client in a Flask app.
from redis import [1]
The Redis client class is named Redis. Importing it allows connecting to the Redis server.
Complete the code to create a Redis client instance connecting to localhost.
redis_client = Redis(host=[1], port=6379, db=0)
To connect to the local Redis server, use 'localhost' as the host.
Fix the error in publishing a message to a Redis channel.
redis_client.[1]('notifications', 'Hello World!')
The correct method to send a message to a Redis channel is publish.
Fill both blanks to subscribe to a Redis channel and listen for messages.
pubsub = redis_client.[1]() pubsub.[2]('updates')
First, create a pubsub object with pubsub(), then subscribe to a channel with subscribe().
Fill all three blanks to receive and print messages from a Redis subscription.
for message in pubsub.[1](): if message['[2]'] == 'message': print(message['[3]'])
Use listen() to get messages, check if type == 'message' (message type), then print the data content.