-
-
Notifications
You must be signed in to change notification settings - Fork 16.8k
Closed
Description
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return [1, 2, 3]
if __name__ == '__main__':
app.run()It will raise 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.
Then I have to do like this.
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/')
def index():
return jsonify([1, 2, 3])
if __name__ == '__main__':
app.run()And I found that a dict can be jsonify automatically in app.py#L1924
So why does flask can't jsonify a list like a dict ?
Reactions are currently unavailable