Home / Function/ ok() — requests Function Reference

ok() — requests Function Reference

Architecture documentation for the ok() function in models.py from the requests codebase.

Entity Profile

Dependency Diagram

graph TD
  aa4a4768_e39e_c956_e629_331246c4b8df["ok()"]
  eb32847e_3797_d01a_6e44_345e9ea7e251["Response"]
  aa4a4768_e39e_c956_e629_331246c4b8df -->|defined in| eb32847e_3797_d01a_6e44_345e9ea7e251
  0ff85151_95cf_f245_0e4f_aea80330b552["raise_for_status()"]
  aa4a4768_e39e_c956_e629_331246c4b8df -->|calls| 0ff85151_95cf_f245_0e4f_aea80330b552
  style aa4a4768_e39e_c956_e629_331246c4b8df fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/requests/models.py lines 757–769

    def ok(self):
        """Returns True if :attr:`status_code` is less than 400, False if not.

        This attribute checks if the status code of the response is between
        400 and 600 to see if there was a client error or a server error. If
        the status code is between 200 and 400, this will return True. This
        is **not** a check to see if the response code is ``200 OK``.
        """
        try:
            self.raise_for_status()
        except HTTPError:
            return False
        return True

Domain

Subdomains

Frequently Asked Questions

What does ok() do?
ok() is a function in the requests codebase, defined in src/requests/models.py.
Where is ok() defined?
ok() is defined in src/requests/models.py at line 757.
What does ok() call?
ok() calls 1 function(s): raise_for_status.

Analyze Your Own Codebase

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

Try Supermodel Free