0

I have tried Passing HTML to template using Flask/Jinja2 , converting json to string in python , How to access session variables in jinja 2 - Flask , how to send data from a python file to html file that are in a separate projects via a url (not having html as a template)

I am trying to pass a variable that was stored in flask sessions to html but the html tags are showing up like they are escaped. I have tried to us-escape them, decode them from unicode, decode them to from JSON, use flask markup with passing them as {{ variable|safe }}, parsing them (although I didn't think this was the problem anyway), and passing the varible in directly {{session['final']}}. All to no avail. And here is my code

...
final = '<p>' + Plast + ', ' + Pfirst + ' ' + Pmiddle + '. ' + '“' + PartTitle + '.' + '” ' + '<i>' + PwebTitle + '</i>' + ', ' + Ppublish + ', ' + Pday + ' ' + Pmonth + '. ' + Pyear + ', ' + Purl + '.' + '</p>'

session['final'] = final
return redirect(url_for('final'))
@app.route('/final', methods=['GET'])
def final():
    inpre = session['final']
    outpost = Markup(inpre)
    return render_template("final.html", finalCite=outpost)

Html

<div id="text">{{ finalCite|safe }}</div>

The problem is that the variable is returned to the web page as <p>...<i>content</i>...</p> and not as ...content...

Filtered
  • 65
  • 1
  • 8

0 Answers0