forked from orbit-oss/flask
Fixed a broken example in the docs
This commit is contained in:
parent
f5d2d324b5
commit
e75322206d
1 changed files with 4 additions and 1 deletions
|
|
@ -628,7 +628,9 @@ unless he knows the secret key used for signing.
|
||||||
In order to use sessions you have to set a secret key. Here is how
|
In order to use sessions you have to set a secret key. Here is how
|
||||||
sessions work::
|
sessions work::
|
||||||
|
|
||||||
from flask import session, redirect, url_for, escape
|
from flask import Flask, session, redirect, url_for, escape, request
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
|
|
@ -652,6 +654,7 @@ sessions work::
|
||||||
def logout():
|
def logout():
|
||||||
# remove the username from the session if its there
|
# remove the username from the session if its there
|
||||||
session.pop('username', None)
|
session.pop('username', None)
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
# set the secret key. keep this really secret:
|
# set the secret key. keep this really secret:
|
||||||
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
|
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue