Yarden
Yarden

Reputation: 679

Insert paragraph from Python Flask to HTML

I'm new to Flask in Python. I've managed to transfer values from my python code to an HTML page. I'm trying to transfer one value which is actually a long paragraph. I have a loop creating this long text:

google_str += num + '. ' + title + '\n' + url + '\n'

I want this to eventually look like this in HTML:

  1. Title1
    URL1
  2. Title2
    URL2

etc.

I'm sending it to HTML like this:

return render_template('searchtool.html', google_str = google_str)

But then I see the text as one big paragraph without the new lines. How can this be solved?

Upvotes: 1

Views: 1238

Answers (1)

Yarden
Yarden

Reputation: 679

Found what I was looking for.

First, I had to use "< br >" instead of '/n'. Second, use this in my HTML:

{{google_str|safe}}

This is where I found the answer.

Upvotes: 1

Related Questions