python-scripts/23_flask_session_test.py
2015-10-15 22:51:07 +01:00

22 lines
362 B
Python
Executable File

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)