J
J
Jekson2019-03-22 16:56:06
Flask
Jekson, 2019-03-22 16:56:06

How to configure flask to save session in Redis?

I'm trying to set up sessions with flask-session . When adding the last line to your config file

import os
import redis

POSTGRES = {
    'user': 'dbuser',
    'pw': 'dbadmin',
    'db': 'beedb',
    'host': 'localhost',
    'port': '5432',
}


class Configuration(object):
    DEBUG = True
    SECRET_KEY = os.environ.get('SECRET_KEY') or 'e5ac358c-f0bf-11e5-9e39-d3b532c10a28'
    SQLALCHEMY_DATABASE_URI = 'postgresql://%(user)s:%(pw)[email protected]%(host)s:%(port)s/%(db)s' % POSTGRES
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SESSION_TYPE = 'redis'
    SESSION_REDIS = redis.from_url('localhost:6379')

I get an error
ValueError: Redis URL must specify one of the followingschemes (redis://, rediss://, unix://)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2019-03-22
@fox_12

Well... - and read the text of the error itself and specify the url ' redis://localhost:6379 ' as you are offered in the error itself - have you tried it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question