Home / Class/ Response Class — flask Architecture

Response Class — flask Architecture

Architecture documentation for the Response class in wrappers.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  d37e98da_a97c_3126_ebd5_0a54e0ea9b29["Response"]
  fb9bd0c5_9d0a_c235_58cf_8d691dde64fb["wrappers.py"]
  d37e98da_a97c_3126_ebd5_0a54e0ea9b29 -->|defined in| fb9bd0c5_9d0a_c235_58cf_8d691dde64fb
  e0ce7dfa_ee3c_947a_cab4_1aef7ef5d788["max_cookie_size()"]
  d37e98da_a97c_3126_ebd5_0a54e0ea9b29 -->|method| e0ce7dfa_ee3c_947a_cab4_1aef7ef5d788

Relationship Graph

Source Code

src/flask/wrappers.py lines 222–257

class Response(ResponseBase):
    """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`.
    """

    default_mimetype: str | None = "text/html"

    json_module = json

    autocorrect_location_header = False

    @property
    def max_cookie_size(self) -> int:  # type: ignore
        """Read-only view of the :data:`MAX_COOKIE_SIZE` config key.

        See :attr:`~werkzeug.wrappers.Response.max_cookie_size` in
        Werkzeug's docs.
        """
        if current_app:
            return current_app.config["MAX_COOKIE_SIZE"]  # type: ignore[no-any-return]

        # return Werkzeug's default when not in an app context
        return super().max_cookie_size

Frequently Asked Questions

What is the Response class?
Response is a class in the flask codebase, defined in src/flask/wrappers.py.
Where is Response defined?
Response is defined in src/flask/wrappers.py at line 222.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free