forked from orbit-oss/flask
Allow dictionary return values as JSON
This supports an increasingly common usecase whereby JSON is the
primary response (rather than a templated string). Given Flask has a
short syntax for HTML reponses, it seems fitting that it should also
do so for JSON responses. In practice it allows,
@app.route("/")
def index():
return {
"api_stuff": "values",
}
This commit is contained in:
parent
2616d97f32
commit
7bf8366970
4 changed files with 37 additions and 16 deletions
|
|
@ -52,6 +52,10 @@ Unreleased
|
|||
- Add an ``--extra-files`` option to the ``flask run`` CLI command to
|
||||
specify extra files that will trigger the reloader on change.
|
||||
:issue:`2897`
|
||||
- Allow returning a dictionary from a view function. Similar to how
|
||||
returning a string will produce a ``text/html`` response, returning
|
||||
a dict will call ``jsonify`` to produce a ``application/json``
|
||||
response. :pr:`3111`
|
||||
|
||||
.. _#2935: https://github.com/pallets/flask/issues/2935
|
||||
.. _#2957: https://github.com/pallets/flask/issues/2957
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue