Participer au site avec un Tip
Rechercher
 

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 :

Module « flask.wrappers »

Classe « Response »

Informations générales

Héritage

builtins.object
    Response
        Response
            Response

Définition

class Response(Response):

Description [extrait de Response.__doc__]

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`.
    

Constructeur(s)

Signature du constructeur Description
__init__(self, response: Union[Iterable[bytes], bytes, Iterable[str], str, NoneType] = None, status: Union[int, str, http.HTTPStatus, NoneType] = None, headers: Union[Mapping[str, Union[str, int, Iterable[Union[str, int]]]], Iterable[Tuple[str, Union[str, int]]], NoneType] = None, mimetype: Optional[str] = None, content_type: Optional[str] = None, direct_passthrough: bool = False) -> None

Liste des attributs statiques

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_headerTrue
automatically_set_content_lengthTrue
charsetutf-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_mimetypetext/html
default_status200
expires<header_property Expires>
implicit_sequence_conversionTrue
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>

Attributs statiques hérités de la classe Response

max_cookie_size

Liste des propriétés

Nom de la propriétéDescription
access_control_allow_credentialsWhether credentials can be shared by the browser to [extrait de __doc__]
allowThe Allow entity-header field lists the set of methods [extrait de __doc__]
cache_controlThe Cache-Control general-header field is used to specify [extrait de __doc__]
content_languageThe Content-Language entity-header field describes the [extrait de __doc__]
content_rangeThe ``Content-Range`` header as a [extrait de __doc__]
content_security_policyThe ``Content-Security-Policy`` header as a [extrait de __doc__]
content_security_policy_report_onlyThe ``Content-Security-policy-report-only`` header as a [extrait de __doc__]
dataA descriptor that calls :meth:`get_data` and :meth:`set_data`. [extrait de __doc__]
is_jsonCheck if the mimetype indicates JSON data, either [extrait de __doc__]
is_sequenceIf the iterator is buffered, this property will be `True`. A [extrait de __doc__]
is_streamedIf the response is streamed (the response is not an iterable with [extrait de __doc__]
jsonThe parsed JSON data if :attr:`mimetype` indicates JSON [extrait de __doc__]
max_cookie_sizeRead-only view of the :data:`MAX_COOKIE_SIZE` config key. [extrait de __doc__]
mimetypeThe mimetype (content type without charset etc.) [extrait de __doc__]
mimetype_paramsThe mimetype parameters as dict. For example if the [extrait de __doc__]
retry_afterThe Retry-After response-header field can be used with a [extrait de __doc__]
statusThe HTTP status code as a string. [extrait de __doc__]
status_codeThe HTTP status code as a number. [extrait de __doc__]
streamThe response iterable as write-only stream. [extrait de stream.__doc__]
varyThe Vary field value indicates the set of request-header [extrait de __doc__]
www_authenticateThe ``WWW-Authenticate`` header in a parsed form. [extrait de __doc__]

Liste des opérateurs

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
__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__]

Méthodes héritées de la classe Response

__init_subclass__, __subclasshook__

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__