builtins.object Response Response Response
class Response(Response):
The response object that is used by default in Flask. Works like the response object from Werkzeug but is set to have an HTML mimetype by default. Quite often you don't have to create this object yourself because :meth:`~flask.Flask.make_response` will take care of that for you. If you want to replace the response object used you can subclass this and set :attr:`~flask.Flask.response_class` to your subclass. .. versionchanged:: 1.0 JSON support is added to the response, like the request. This is useful when testing to get the test client response data as JSON. .. versionchanged:: 1.0 Added :attr:`max_cookie_size`.
Nom de l'attribut | Valeur |
---|---|
accept_ranges | <header_property Accept-Ranges> |
access_control_allow_headers | <header_property Access-Control-Allow-Headers> |
access_control_allow_methods | <header_property Access-Control-Allow-Methods> |
access_control_allow_origin | <header_property Access-Control-Allow-Origin> |
access_control_expose_headers | <header_property Access-Control-Expose-Headers> |
access_control_max_age | <header_property Access-Control-Max-Age> |
age | <header_property Age> |
autocorrect_location_header | False |
automatically_set_content_length | True |
content_encoding | <header_property Content-Encoding> |
content_length | <header_property Content-Length> |
content_location | <header_property Content-Location> |
content_md5 | <header_property Content-MD5> |
content_type | <header_property Content-Type> |
cross_origin_embedder_policy | <header_property Cross-Origin-Embedder-Policy> |
cross_origin_opener_policy | <header_property Cross-Origin-Opener-Policy> |
date | <header_property Date> |
default_mimetype | text/html |
default_status | 200 |
expires | <header_property Expires> |
implicit_sequence_conversion | True |
json_module | <module 'flask.json' from 'C:\\Users\\domin\\Desktop\\Developpements\\EclipseWorkspace\\KooR\\_ApiPython\\venv\\Lib\\site-packages\\flask\\json\\__init__.py'> |
last_modified | <header_property Last-Modified> |
location | <header_property Location> |
Nom de la propriété | Description |
---|---|
access_control_allow_credentials | Whether credentials can be shared by the browser to [extrait de access_control_allow_credentials.__doc__] |
allow | The Allow entity-header field lists the set of methods [extrait de allow.__doc__] |
cache_control | The Cache-Control general-header field is used to specify [extrait de cache_control.__doc__] |
content_language | The Content-Language entity-header field describes the [extrait de content_language.__doc__] |
content_range | The ``Content-Range`` header as a [extrait de content_range.__doc__] |
content_security_policy | The ``Content-Security-Policy`` header as a [extrait de content_security_policy.__doc__] |
content_security_policy_report_only | The ``Content-Security-policy-report-only`` header as a [extrait de content_security_policy_report_only.__doc__] |
data | A descriptor that calls :meth:`get_data` and :meth:`set_data`. [extrait de data.__doc__] |
is_json | Check if the mimetype indicates JSON data, either [extrait de is_json.__doc__] |
is_sequence | If the iterator is buffered, this property will be `True`. A [extrait de is_sequence.__doc__] |
is_streamed | If the response is streamed (the response is not an iterable with [extrait de is_streamed.__doc__] |
json | The parsed JSON data if :attr:`mimetype` indicates JSON [extrait de json.__doc__] |
max_cookie_size | Read-only view of the :data:`MAX_COOKIE_SIZE` config key. [extrait de max_cookie_size.__doc__] |
mimetype | The mimetype (content type without charset etc.) [extrait de mimetype.__doc__] |
mimetype_params | The mimetype parameters as dict. For example if the [extrait de mimetype_params.__doc__] |
retry_after | The Retry-After response-header field can be used with a [extrait de retry_after.__doc__] |
status | The HTTP status code as a string. [extrait de status.__doc__] |
status_code | The HTTP status code as a number. [extrait de status_code.__doc__] |
stream | The response iterable as write-only stream. [extrait de stream.__doc__] |
vary | The Vary field value indicates the set of request-header [extrait de vary.__doc__] |
www_authenticate | The ``WWW-Authenticate`` header parsed into a :class:`.WWWAuthenticate` [extrait de www_authenticate.__doc__] |
Signature de la méthode | Description |
---|---|
__call__(self, environ: 'WSGIEnvironment', start_response: 'StartResponse') -> 't.Iterable[bytes]' | Process this response as WSGI application. [extrait de __call__.__doc__] |
__enter__(self) -> 'Response' | |
__exit__(self, exc_type, exc_value, tb) | |
__repr__(self) -> 'str' | |
add_etag(self, overwrite: 'bool' = False, weak: 'bool' = False) -> 'None' | Add an etag for the current response if there is none yet. [extrait de add_etag.__doc__] |
calculate_content_length(self) -> 'int | None' | Returns the content length if available or `None` otherwise. [extrait de calculate_content_length.__doc__] |
call_on_close(self, func: 't.Callable[[], t.Any]') -> 't.Callable[[], t.Any]' | Adds a function to the internal list of functions that should [extrait de call_on_close.__doc__] |
close(self) -> 'None' | Close the wrapped response if possible. You can also use the object [extrait de close.__doc__] |
delete_cookie(self, key: 'str', path: 'str | None' = '/', domain: 'str | None' = None, secure: 'bool' = False, httponly: 'bool' = False, samesite: 'str | None' = None, partitioned: 'bool' = False) -> 'None' | Delete a cookie. Fails silently if key doesn't exist. [extrait de delete_cookie.__doc__] |
force_type(response: 'Response', environ: 'WSGIEnvironment | None' = None) -> 'Response' | Enforce that the WSGI response is a response object of the current [extrait de force_type.__doc__] |
freeze(self) -> 'None' | Make the response object ready to be pickled. Does the [extrait de freeze.__doc__] |
from_app(app: 'WSGIApplication', environ: 'WSGIEnvironment', buffered: 'bool' = False) -> 'Response' | Create a new response object from an application output. This [extrait de from_app.__doc__] |
get_app_iter(self, environ: 'WSGIEnvironment') -> 't.Iterable[bytes]' | Returns the application iterator for the given environ. Depending [extrait de get_app_iter.__doc__] |
get_data(self, as_text: 'bool' = False) -> 'bytes | str' | The string representation of the response body. Whenever you call [extrait de get_data.__doc__] |
get_etag(self) -> 'tuple[str, bool] | tuple[None, None]' | Return a tuple in the form ``(etag, is_weak)``. If there is no [extrait de get_etag.__doc__] |
get_json(self, force: 'bool' = False, silent: 'bool' = False) -> 't.Any | None' | Parse :attr:`data` as JSON. Useful during testing. [extrait de get_json.__doc__] |
get_wsgi_headers(self, environ: 'WSGIEnvironment') -> 'Headers' | This is automatically called right before the response is started [extrait de get_wsgi_headers.__doc__] |
get_wsgi_response(self, environ: 'WSGIEnvironment') -> 'tuple[t.Iterable[bytes], str, list[tuple[str, str]]]' | Returns the final WSGI response as tuple. The first item in [extrait de get_wsgi_response.__doc__] |
iter_encoded(self) -> 't.Iterator[bytes]' | Iter the response encoded with the encoding of the response. [extrait de iter_encoded.__doc__] |
make_conditional(self, request_or_environ: 'WSGIEnvironment | Request', accept_ranges: 'bool | str' = False, complete_length: 'int | None' = None) -> 'Response' | Make the response conditional to the request. This method works [extrait de make_conditional.__doc__] |
make_sequence(self) -> 'None' | Converts the response iterator in a list. By default this happens [extrait de make_sequence.__doc__] |
set_cookie(self, key: 'str', value: 'str' = '', max_age: 'timedelta | int | None' = None, expires: 'str | datetime | int | float | None' = None, path: 'str | None' = '/', domain: 'str | None' = None, secure: 'bool' = False, httponly: 'bool' = False, samesite: 'str | None' = None, partitioned: 'bool' = False) -> 'None' | Sets a cookie. [extrait de set_cookie.__doc__] |
set_data(self, value: 'bytes | str') -> 'None' | Sets a new string as response. The value must be a string or [extrait de set_data.__doc__] |
set_etag(self, etag: 'str', weak: 'bool' = False) -> 'None' | Set the etag, and override the old one if there was one. [extrait de set_etag.__doc__] |
Améliorations / Corrections
Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.
Emplacement :
Description des améliorations :