I'm learning the flask web-framework. And encounter this problem. I get some text from user in markdown style, and then transfer it into HTML and store in the database.
title = request.form.get('title')
content = request.form.get('content')
html = markdown(content)
newPost = Article(title, html)
db.session.add(newPost)
db.session.commit()
When I extract the title and content from database and insert it into HTML directly, seems didn't work.
#view.py
articles = Article.query.all()
print(articles[0].body) # <h3>Test</h3>
<div class="container mb-5">
<span class="row">
<h4>{{ articles[0].title }}</h4>
</span>
<span class="row mt-3 mb-3">
<span class="mr-2"><time>{{ articles[0].pub_date.strftime('%B %d %Y') }}</time></span>
</span>
<div class="row">
{{ articles[0].body }}
</div>
</div>
And I copy that element from chrome developer tool, the body string actually is:
<div class="row">
<h3>Test</h3>
</div>
Is that some thing related to encoding? And what should I do next?
Thanks!