title: Passing json data to template
body: <p>I'm new to flask &amp; web dev.  I want to pass output of an algorithm to template so I can show it to user. But I'm doing something wrong and don't see any output in HTML other then empty bullet points.</p>
  
  <p><strong>routes.py</strong></p>
  
  <pre><code>from flask import Flask, request, jsonify, render_template
  from image_processing import find_cross_v4
  import json
  
  app = Flask(__name__)
  
  def run_algorithms():
          return {'file_name': f.filename, 'set_min': 'hello world 1','rep_sec':'hello world 2'}
  
  @app.route('/upload', methods=['POST'])
  def upload():
     f = request.files['file']
     f.save("image_processing/query.jpg")
     data = run_algorithms()
     #jsondata = jsonify(data)
     #data =json.loads(jsondata)
     return render_template('results.html',data=data)
  
  @app.route('/test',methods=['POST'])
  def test():
    try:
      f = request.files['file']
      f.save("image_processing/query.jpg")
    except KeyError:
      return jsonify({'error': 'File Missing'})
    result = run_algorithms(f)
    return jsonify(result)
  
   if __name__ == "__main__":
    app.debug = True
    app.run(host='0.0.0.0')
  </code></pre>
  
  <p><strong>results.html</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
   &lt;body&gt;
     &lt;h1 class="logo"&gt;Results&lt;/h1&gt;
  
     &lt;ul&gt;
      {% for data in data %}
      &lt;li&gt;{{data.file_name}}&lt;/li&gt;
      &lt;li&gt;{{data.set_min}}&lt;/li&gt;
      &lt;li&gt;{{data.rep_sec}}&lt;/li&gt;
      {% endfor %}
     &lt;/ul&gt;
  
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I hit '/test' from command line </p>
  
  <pre><code>curl --form file=@somefile.jpg http://0.0.0.0:5000/test
  </code></pre>
  
  <p>Got below as output.</p>
  
  <blockquote>
    <p>{
         "file_name": "somefile.jpg", 
         "rep_sec": "hello world 2", 
         "set_min": "hello world 1"     }</p>
  </blockquote>
  
  <p>Results when I try things via browser
  <img src="https://i.stack.imgur.com/P9imq.png" alt="enter image description here"></p>