From 99c906d1ada7dd1d38346d7418498668c7d2868b Mon Sep 17 00:00:00 2001 From: purerosefallen <78877@qq.com> Date: Mon, 6 Apr 2020 16:29:23 +0800 Subject: [PATCH] load redis properly in session --- app.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app.py b/app.py index 903a9dc..d909221 100644 --- a/app.py +++ b/app.py @@ -17,12 +17,19 @@ from flask_session import Session from flask_wtf.csrf import CSRFProtect, generate_csrf, CSRFError from ffmpy import FFmpeg from pymongo import MongoClient +from redis import Redis app = Flask(__name__) client = MongoClient(host=config.MONGO['host']) app.secret_key = config.SECRET_KEY app.config['SESSION_TYPE'] = 'redis' +app.config['SESSION_REDIS'] = Redis( + host=config.REDIS['CACHE_REDIS_HOST'], + port=config.REDIS['CACHE_REDIS_PORT'], + password=config.REDIS['CACHE_REDIS_PASSWORD'], + db=config.REDIS['CACHE_REDIS_DB'] +) app.cache = Cache(app, config=config.REDIS) sess = Session() sess.init_app(app)