Home / Function/ response() — flask Function Reference

response() — flask Function Reference

Architecture documentation for the response() function in provider.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  41f60dba_c742_8eff_04cc_8577b192c235["response()"]
  7dc7dbfa_612a_e2fa_73ef_39f4b6b74ab2["DefaultJSONProvider"]
  41f60dba_c742_8eff_04cc_8577b192c235 -->|defined in| 7dc7dbfa_612a_e2fa_73ef_39f4b6b74ab2
  aec4f243_b66b_1e41_ea9e_51f8c611233d["response()"]
  aec4f243_b66b_1e41_ea9e_51f8c611233d -->|calls| 41f60dba_c742_8eff_04cc_8577b192c235
  9104e3d3_6e3d_cb00_d366_f06b8ffa8caa["_prepare_response_obj()"]
  41f60dba_c742_8eff_04cc_8577b192c235 -->|calls| 9104e3d3_6e3d_cb00_d366_f06b8ffa8caa
  298532b3_e403_bc7d_d6ab_a15e33dea870["dumps()"]
  41f60dba_c742_8eff_04cc_8577b192c235 -->|calls| 298532b3_e403_bc7d_d6ab_a15e33dea870
  aec4f243_b66b_1e41_ea9e_51f8c611233d["response()"]
  41f60dba_c742_8eff_04cc_8577b192c235 -->|calls| aec4f243_b66b_1e41_ea9e_51f8c611233d
  style 41f60dba_c742_8eff_04cc_8577b192c235 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/flask/json/provider.py lines 189–215

    def response(self, *args: t.Any, **kwargs: t.Any) -> Response:
        """Serialize the given arguments as JSON, and return a
        :class:`~flask.Response` object with it. The response mimetype
        will be "application/json" and can be changed with
        :attr:`mimetype`.

        If :attr:`compact` is ``False`` or debug mode is enabled, the
        output will be formatted to be easier to read.

        Either positional or keyword arguments can be given, not both.
        If no arguments are given, ``None`` is serialized.

        :param args: A single value to serialize, or multiple values to
            treat as a list to serialize.
        :param kwargs: Treat as a dict to serialize.
        """
        obj = self._prepare_response_obj(args, kwargs)
        dump_args: dict[str, t.Any] = {}

        if (self.compact is None and self._app.debug) or self.compact is False:
            dump_args.setdefault("indent", 2)
        else:
            dump_args.setdefault("separators", (",", ":"))

        return self._app.response_class(
            f"{self.dumps(obj, **dump_args)}\n", mimetype=self.mimetype
        )

Domain

Subdomains

Called By

Frequently Asked Questions

What does response() do?
response() is a function in the flask codebase, defined in src/flask/json/provider.py.
Where is response() defined?
response() is defined in src/flask/json/provider.py at line 189.
What does response() call?
response() calls 3 function(s): _prepare_response_obj, dumps, response.
What calls response()?
response() is called by 1 function(s): response.

Analyze Your Own Codebase

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

Try Supermodel Free