For example, this code:
from flask import session
@app.route('/is_logged_in/')
def is_logged_in():
return 'user' in session
It runs fine for me when running Flask's development server, but it throws a 500
error with any webserver setup (FastCGI, uWSGI, etc.) on any server (Apache, nginx, Lighttpd).
Anybody know why?
My actual code is on GitHub, if it matters.
It works flawlessly when running with Flask's internal server, but I can't get any session variables to work with a production webserver: https://github.com/Blender3D/Webminal/blob/master/server.py
I finally tried Tornado, thinking it would help with my problems (it's written in Python, after all).
Lo and behold, a readable traceback:
RuntimeError: the session is unavailable because no secret key was set.
Set the secret_key on the application to something unique and secret.
Looks like I just forgot to add a secret key to sign sessions with:
app.secret_key = 'why would I tell you my secret key?'