I am using Flask as the backend and reading a piece of text from a file that contains newlines as \n
. I wish to render this text inside a div. To do so, I am replacing the \n
with <br>
and then passing it to the render_template()
method.
@app.route('/')
@app.route('/index')
def index():
content = read_file('filename.csv')
content = content.replace('\\n','<br>')
return render_tempate('index.html',text=content)
However, doing so shows the br tag as text. The underlying html shows that the br tag is being interpreted as <br>
<div>some text <br> some more text</br>
How can I fix this and render a newline inside the div?