user1070036 user1070036 - 3 months ago 35
Python Question

Python flask flash message exception remains after restarting

I'm making a small flask app where I had something like this:

@app.route('/bye')
def logout():
session.pop('logged_in', None)
flash('AdiĆ³s')
return redirect('/index')


Needless to say when I ran the application and I navigated to '/bye' it gave me a UnicodeDecodeError. Well, now it gives me the same unicodedecodeerror on every page that extends the base template (which renders the messages) even after restarting the application. and always with the same dump() despite removing that flash in the source code. All I can think of is what the crap? Help please.

Well I had to restart my computer to clear the stupid session cache or something.

Answer

I think that flash() actually creates a session called session['_flashes']. See this code here. So you will probably have to either:

clear/delete the cookie 

OR

session.pop('_flashes', None)
Comments