flask session test
This commit is contained in:
parent
a8023a0780
commit
0523b16f80
21
23_flask_session_test.py
Normal file
21
23_flask_session_test.py
Normal file
@ -0,0 +1,21 @@
|
||||
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)
|
Loading…
Reference in New Issue
Block a user