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 | True |
automatically_set_content_length | True |
charset | utf-8 |
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 '/home/dominique/Documents/My Developpements/EclipseWorkspace/Ellipse/KooR/_ApiPython/venv/lib64/python3.10/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 __doc__] |
allow | The Allow entity-header field lists the set of methods [extrait de __doc__] |
cache_control | The Cache-Control general-header field is used to specify [extrait de __doc__] |
content_language | The Content-Language entity-header field describes the [extrait de __doc__] |
content_range | The ``Content-Range`` header as a [extrait de __doc__] |
content_security_policy | The ``Content-Security-Policy`` header as a [extrait de __doc__] |
content_security_policy_report_only | The ``Content-Security-policy-report-only`` header as a [extrait de __doc__] |
data | A descriptor that calls :meth:`get_data` and :meth:`set_data`. [extrait de __doc__] |
is_json | Check if the mimetype indicates JSON data, either [extrait de __doc__] |
is_sequence | If the iterator is buffered, this property will be `True`. A [extrait de __doc__] |
is_streamed | If the response is streamed (the response is not an iterable with [extrait de __doc__] |
json | The parsed JSON data if :attr:`mimetype` indicates JSON [extrait de __doc__] |
max_cookie_size | Read-only view of the :data:`MAX_COOKIE_SIZE` config key. [extrait de __doc__] |
mimetype | The mimetype (content type without charset etc.) [extrait de __doc__] |
mimetype_params | The mimetype parameters as dict. For example if the [extrait de __doc__] |
retry_after | The Retry-After response-header field can be used with a [extrait de __doc__] |
status | The HTTP status code as a string. [extrait de __doc__] |
status_code | The HTTP status code as a number. [extrait de __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 __doc__] |
www_authenticate | The ``WWW-Authenticate`` header in a parsed form. [extrait de __doc__] |
Signature de la méthode | Description |
---|---|
__call__(self, environ: 'WSGIEnvironment', start_response: 'StartResponse') -> 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) -> Optional[int] | Returns the content length if available or `None` otherwise. [extrait de calculate_content_length.__doc__] |
call_on_close(self, func: Callable[[], Any]) -> Callable[[], 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 = '/', domain: Optional[str] = None, secure: bool = False, httponly: bool = False, samesite: Optional[str] = None) -> None | Delete a cookie. Fails silently if key doesn't exist. [extrait de delete_cookie.__doc__] |
force_type(response: 'Response', environ: Optional[ForwardRef('WSGIEnvironment')] = None) -> 'Response' | Enforce that the WSGI response is a response object of the current [extrait de force_type.__doc__] |
freeze(self, no_etag: None = None) -> 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') -> Iterable[bytes] | Returns the application iterator for the given environ. Depending [extrait de get_app_iter.__doc__] |
get_data(self, as_text: bool = False) -> Union[bytes, str] | The string representation of the response body. Whenever you call [extrait de get_data.__doc__] |
get_etag(self) -> Union[Tuple[str, bool], Tuple[NoneType, NoneType]] | 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) -> Optional[Any] | Parse :attr:`data` as JSON. Useful during testing. [extrait de get_json.__doc__] |
get_wsgi_headers(self, environ: 'WSGIEnvironment') -> werkzeug.datastructures.Headers | This is automatically called right before the response is started [extrait de get_wsgi_headers.__doc__] |
get_wsgi_response(self, environ: 'WSGIEnvironment') -> Tuple[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) -> Iterator[bytes] | Iter the response encoded with the encoding of the response. [extrait de iter_encoded.__doc__] |
make_conditional(self, request_or_environ: 'WSGIEnvironment', accept_ranges: Union[bool, str] = False, complete_length: Optional[int] = 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: Union[datetime.timedelta, int, NoneType] = None, expires: Union[str, datetime.datetime, int, float, NoneType] = None, path: Optional[str] = '/', domain: Optional[str] = None, secure: bool = False, httponly: bool = False, samesite: Optional[str] = None) -> None | Sets a cookie. [extrait de set_cookie.__doc__] |
set_data(self, value: Union[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 :