0

I'm trying to pass a variable to a render_template as html code, but Flask automatically changes the strings instead of returning the plaintext. For instance, if I were to try to say:

@app.route("/")
def index():
 return render_template("index.html", code = "<p>Hello</p>")

Flask passes the variable "code" to the website as:

<p> Hello </p>

So it renders out to just be

Hello

instead of recognizing the HTML tags. Is there any way to fix this?

efish1824
  • 1
  • 2
  • [Answer](https://stackoverflow.com/questions/3206344/passing-html-to-template-using-flask-jinja2/3266740#3266740) – PGHE Mar 11 '22 at 01:18
  • what are the contents of index.html? – okayatcp12 Mar 11 '22 at 01:56
  • Update: @PGHE linked me to an [answer](https://stackoverflow.com/questions/3206344/passing-html-to-template-using-flask-jinja2/3266740#3266740). This question is resolved – efish1824 Mar 11 '22 at 02:04

0 Answers0