0

For this route:

@app.route("/<string:c_id>/br")
def br(c_id):
    mydb = mysql.connector.connect(...)
    mycursor = mydb.cursor()
    mycursor.execute("USE ...)
    mycursor.execute("SELECT * FROM Bank;")
    BR = mycursor.fetchone()
    BR = BR[1]
    mydb.close()
    return render_template('twelve.html',BR=BR,c_id=c_id)

BR is a string, written in HTML, e.g. BR = r'<h1>To sort </h1> <i>to be completed</i>' Which is part of a database. Fetching BR from the database gives: <h1>To sort </h1> <i>to be completed</i>

I would like to include this into my template - twelve.html

twelve.html:

{% extends "layout.html" %}
{% block title %}This Page{% endblock %}
{% block head %}
  {{ super() }}
  <style type="text/css">
    .important { color: #336699; }
  </style>
{% endblock %}
{% block content %}

<h2>This Page</h2>

{{ BR }}

{% endblock %}

Currently the webpage reads,<h1>To sort </h1> <i>to be completed</i>

How do I get it to read the HTML tags, and use them? So it actually looks something like this:

To sort

to be completed

1 Answer 1

1

Try this:

{{ BR|safe }}

This is called a filter. Read more about them here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.