Flask UnicodeDecodeError Flask UnicodeDecodeError flask flask

Flask UnicodeDecodeError


Try passing a unicode object, not a str into render_template(), like so:

render_template('signUpSuccess.html', password=u"You should know, right? 😛")

Sample program:

# coding: utf-8from flask import Flask, render_templateapp = Flask(__name__)@app.route('/')def root():    return render_template('signUpSuccess.html', password=u"You should know, right? 😛")if __name__=="__main__":    app.run(debug=True)

template:

<html>password: {{ password }}</html>


You should decode that string. Try this:

the_password = "You should know, right? 😛"the_password = the_password.decode('utf-8')render_template('signUpSuccess.html', password=the_password)