title: Display MongoDB Documents data on a Webpage using Python Flask
body: <p>I wrote a code using Python and trying to display all the Documents from Mongodb on a web page. However, on webpage I see the Column names, but no data.
  And on the command, it does print all the data. Any help is greatly appreciated.</p>
  
  <pre><code>import pymongo
  from pymongo import MongoClient
  import datetime
  import sys
  from flask import Flask, render_template, request
  import werkzeug
  from flask_table import Table,Col
  from bson.json_util import dumps
  import json
  
  app = Flask(__name__)
  
  try:
   client = pymongo.MongoClient("XXXX")
   print("Connected to Avengers MongoClient Successfully from Project 
   Script!!!")
  except:
   print("Connection to MongoClient Failed!!!")
  
  db = client.avengers_hack_db
  
  @app.route('/')
  def Results():
      try:
          Project_List_Col = db.ppm_master_db_collection.find()#.limit(10)
          for row in Project_List_Col:
          print(row)
          return render_template('Results.html',tasks=row)
  
      except Exception as e:
      return dumps({'error': str(e)})
  
  if __name__ == '__main__':  
     app.run(debug = True)
  </code></pre>
  
  <p>The HTML (Results.html) Page is:</p>
  
  <pre><code>&lt;html&gt;
    &lt;body&gt;
       {% for task_id in tasks %}
          &lt;h3&gt;{{task_id}}&lt;/h3&gt;
       {% endfor %}
     &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>