The answers given above are correct. Flag views are expected to return some kind of HTTP response. Therefore, you need to process the data and make an answer, perhaps using the functions of the Flasks utility. In addition, the find() method returns a cursor that you need to iterate over at some point.
You just need to change the last line of the form:
@app.route('/') def home_page(): post = {"author":"mike","text":"jiii"} posts = db.posts posts.insert(post) return render_template(posts.find(), "index.html")
And specify index.html , which contains something like:
{% for post in posts %} <h2>Post by {{ post.author}}</h2> <p>{{ post.text }}</p> {% endfor %}
Eric Schrijver
source share