G
G
Ganki2019-02-23 11:44:03
Flask
Ganki, 2019-02-23 11:44:03

How to replace newline character with tag?

Thanks in advance for your replies
. I'm writing a Flask app with a simple message input form. The message is entered and stored in the database. But the whole message is obtained in one line.
Please tell me how, when displaying a message, translate newline characters ("\r\n", "\r", "\n") into the tag
# model.py (model in the database)

class Post(db.Model):
    __tablename__ = 'posts'
    id = db.Column(db.Integer, primary_key=True)
    body = db.Column(db.Text)

#index.html
<html>
  <head>
    <title>WWW Site</title>
  </head>
  <body>
    {{ post.body }}
  </body>
</html>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2019-02-24
@dimonchik2013

replace

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question