Created
January 7, 2015 02:47
-
-
Save davidism/ff2f8d3d42e2fc909114 to your computer and use it in GitHub Desktop.
Flask session test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from flask import Flask, session, url_for, redirect | |
app = Flask(__name__) | |
app.secret_key = 'secret' | |
@app.route('/') | |
def set(): | |
session.clear() | |
session['works'] = True | |
return redirect(url_for('get')) | |
@app.route('/get') | |
def get(): | |
works = session.get('works', False) | |
return str(works) | |
app.run(sys.argv[1], use_reloader=False) | |
# run on localhost, go to http://localhost:5000/ in Firfox and Chrome, confirm "True" is returned | |
# python app.py localhost | |
# run on 127.0.0.1, go to http://127.0.0.1:5000 in Firefox and Chrome, confirm "True" is returned | |
# python app.py 127.0.0.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment