实验代码:
# -*- coding: utf-8 -*-
"""
Hello
~~~~~
Flask-Session demo.
:copyright: (c) 2014 by Shipeng Feng.
:license: BSD, see LICENSE for more details.
"""
from flask import Flask, session
from flask.ext.session import Session
SESSION_TYPE = 'redis'
app = Flask(__name__)
app.config.from_object(__name__)
Session(app)
@app.route('/set/')
def set():
session['key1'] = 'value1'
session['key2'] = 'value2'
return 'ok'
@app.route('/get/')
def get():
return session.get('key1', 'not set')+session.get('key2', 'not set')
if __name__ == "__main__":
app.run(host='0.0.0.0',threaded=True,debug=True)
-----------------------------------------------------------------------
用redis-cli观察