Home / Function/ __init__() — flask Function Reference

__init__() — flask Function Reference

Architecture documentation for the __init__() function in testing.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  33dc35c6_266a_5b22_e680_684511859331["__init__()"]
  7460417c_4950_0f33_33b8_5c4d83805bac["EnvironBuilder"]
  33dc35c6_266a_5b22_e680_684511859331 -->|defined in| 7460417c_4950_0f33_33b8_5c4d83805bac
  dd770ec8_c848_909d_cc1c_2082f8bc5b07["get()"]
  33dc35c6_266a_5b22_e680_684511859331 -->|calls| dd770ec8_c848_909d_cc1c_2082f8bc5b07
  style 33dc35c6_266a_5b22_e680_684511859331 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/flask/testing.py lines 49–86

    def __init__(
        self,
        app: Flask,
        path: str = "/",
        base_url: str | None = None,
        subdomain: str | None = None,
        url_scheme: str | None = None,
        *args: t.Any,
        **kwargs: t.Any,
    ) -> None:
        assert not (base_url or subdomain or url_scheme) or (
            base_url is not None
        ) != bool(subdomain or url_scheme), (
            'Cannot pass "subdomain" or "url_scheme" with "base_url".'
        )

        if base_url is None:
            http_host = app.config.get("SERVER_NAME") or "localhost"
            app_root = app.config["APPLICATION_ROOT"]

            if subdomain:
                http_host = f"{subdomain}.{http_host}"

            if url_scheme is None:
                url_scheme = app.config["PREFERRED_URL_SCHEME"]

            url = urlsplit(path)
            base_url = (
                f"{url.scheme or url_scheme}://{url.netloc or http_host}"
                f"/{app_root.lstrip('/')}"
            )
            path = url.path

            if url.query:
                path = f"{path}?{url.query}"

        self.app = app
        super().__init__(path, base_url, *args, **kwargs)

Subdomains

Calls

Frequently Asked Questions

What does __init__() do?
__init__() is a function in the flask codebase, defined in src/flask/testing.py.
Where is __init__() defined?
__init__() is defined in src/flask/testing.py at line 49.
What does __init__() call?
__init__() calls 1 function(s): get.

Analyze Your Own Codebase

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

Try Supermodel Free