Skip to content
Myr

Documentation updates

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Adam Byrtek · committed by Markus Unterwaditzer · parent 5575faa · Browse files · 3 files+6 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+6 added−4 removed

  • other:+6 added−4 removed

3 files+6 added−4 removed

modified:docs/api.rst+2 added-2 removed
27 unmodified lines
28Incoming Request Data29---------------------3031.. autoclass:: Request32 :members:32 :members: is_json, get_json3334 .. attribute:: form3536 A :class:`~werkzeug.datastructures.MultiDict` with the parsed form data from ``POST``
103 unmodified lines
140Response Objects141----------------142143.. autoclass:: flask.Response144 :members: set_cookie, data, mimetype144 :members: set_cookie, data, mimetype, is_json, get_json145146 .. attribute:: headers147148 A :class:`~werkzeug.datastructures.Headers` object representing the response headers.
749 unmodified lines
modified:docs/testing.rst+3 added-1 removed
360 unmodified lines
361.. versionadded:: 1.0362363Flask has great support for JSON, and is a popular choice for building REST364APIs. Testing both JSON requests and responses using the test client is very365convenient:365convenient::366367 from flask import jsonify368369 @app.route('/api/auth')370 def auth():371 json_data = request.get_json()372 email = json_data['email']373 password = json_data['password']374375 return jsonify(token=generate_token(email, password))376377 with app.test_client() as c:378 email = 'john@example.com'379 password = 'secret'380 resp = c.post('/api/auth', json={'login': email, 'password': password})381382 json_data = resp.get_json()383 assert verify_token(email, json_data['token'])384385Note that if the ``json`` argument is provided then the test client will put
2 unmodified lines
modified:flask/wrappers.py+1 added-1 removed
55 unmodified lines
56 return getter(cache=cache)57 return self.data5859 def get_json(self, force=False, silent=False, cache=True):60 """Parses the incoming JSON request data and returns it. By default60 """Parses the JSON request/response data and returns it. By default61 this function will return ``None`` if the mimetype is not62 :mimetype:`application/json` but this can be overridden by the63 ``force`` parameter. If parsing fails the64 :meth:`on_json_loading_failed` method on the request object will be
152 unmodified lines