title: Flask REST API Error: The view function did not return a valid response
body: <p>In a Flask REST API route in Python, the return type is a <code>list</code>    </p>
  
  <pre><code>@app.route('/ent', methods=['POST'])
  def ent():
      """Get entities for displaCy ENT visualizer."""
      json = request.get_json()
      nlp = MODELS[json['model']]
      doc = nlp(json['text'])
      return [
          {"start": ent.start_char, "end": ent.end_char, "label": ent.label_}
          for ent in doc.ents
      ]
  </code></pre>
  
  <p>This errors with: </p>
  
  <pre><code>TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a list.
  </code></pre>
  
  <p>How can I get the API route on <code>/ent</code> to return a JSON array correctly?</p>