Home / File/ helpers.py — flask Source File

helpers.py — flask Source File

Architecture documentation for helpers.py, a python file in the flask codebase. 13 imports, 6 dependents.

File python ApplicationCore Scaffolding 13 imports 6 dependents 16 functions

Entity Profile

Dependency Diagram

graph LR
  881f9803_28d6_7d77_c8d7_1098b41ccf84["helpers.py"]
  9cff5a62_7dbb_7b80_cf3c_128a7a2fda28["globals.py"]
  881f9803_28d6_7d77_c8d7_1098b41ccf84 --> 9cff5a62_7dbb_7b80_cf3c_128a7a2fda28
  f7678070_c632_9fab_268f_e2310036493f["signals.py"]
  881f9803_28d6_7d77_c8d7_1098b41ccf84 --> f7678070_c632_9fab_268f_e2310036493f
  fb9bd0c5_9d0a_c235_58cf_8d691dde64fb["wrappers.py"]
  881f9803_28d6_7d77_c8d7_1098b41ccf84 --> fb9bd0c5_9d0a_c235_58cf_8d691dde64fb
  d37e98da_a97c_3126_ebd5_0a54e0ea9b29["Response"]
  881f9803_28d6_7d77_c8d7_1098b41ccf84 --> d37e98da_a97c_3126_ebd5_0a54e0ea9b29
  e2103321_f71b_de04_724e_2b923350399d["importlib.util"]
  881f9803_28d6_7d77_c8d7_1098b41ccf84 --> e2103321_f71b_de04_724e_2b923350399d
  bdc6911d_da67_3a1f_90cb_90f5e9f0603e["os"]
  881f9803_28d6_7d77_c8d7_1098b41ccf84 --> bdc6911d_da67_3a1f_90cb_90f5e9f0603e
  8e9cc1cb_fabe_237c_ff24_85400e094882["sys"]
  881f9803_28d6_7d77_c8d7_1098b41ccf84 --> 8e9cc1cb_fabe_237c_ff24_85400e094882
  d3e9218c_bf0a_48f5_15c9_90795af6f3ac["typing.py"]
  881f9803_28d6_7d77_c8d7_1098b41ccf84 --> d3e9218c_bf0a_48f5_15c9_90795af6f3ac
  bdb4799f_8b0c_fcfd_51cc_f0b833652f8f["datetime"]
  881f9803_28d6_7d77_c8d7_1098b41ccf84 --> bdb4799f_8b0c_fcfd_51cc_f0b833652f8f
  3eebf5bc_1ef0_6524_701b_beec8ec8524a["functools"]
  881f9803_28d6_7d77_c8d7_1098b41ccf84 --> 3eebf5bc_1ef0_6524_701b_beec8ec8524a
  d04b8dfd_bc0a_e096_b08f_f16e74bf9488["werkzeug.utils"]
  881f9803_28d6_7d77_c8d7_1098b41ccf84 --> d04b8dfd_bc0a_e096_b08f_f16e74bf9488
  9b468bc7_cc0b_fef2_ed71_07b4f027fb55["werkzeug.exceptions"]
  881f9803_28d6_7d77_c8d7_1098b41ccf84 --> 9b468bc7_cc0b_fef2_ed71_07b4f027fb55
  22ed428d_d5d1_64b4_e96c_29b42f8212ff["werkzeug.wrappers"]
  881f9803_28d6_7d77_c8d7_1098b41ccf84 --> 22ed428d_d5d1_64b4_e96c_29b42f8212ff
  e1ae29a1_73d3_d5e9_3fd5_548f4ac50138["__init__.py"]
  e1ae29a1_73d3_d5e9_3fd5_548f4ac50138 --> 881f9803_28d6_7d77_c8d7_1098b41ccf84
  style 881f9803_28d6_7d77_c8d7_1098b41ccf84 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from __future__ import annotations

import importlib.util
import os
import sys
import typing as t
from datetime import datetime
from functools import cache
from functools import update_wrapper

import werkzeug.utils
from werkzeug.exceptions import abort as _wz_abort
from werkzeug.utils import redirect as _wz_redirect
from werkzeug.wrappers import Response as BaseResponse

from .globals import _cv_app
from .globals import app_ctx
from .globals import current_app
from .globals import request
from .globals import session
from .signals import message_flashed

if t.TYPE_CHECKING:  # pragma: no cover
    from .wrappers import Response


def get_debug_flag() -> bool:
    """Get whether debug mode should be enabled for the app, indicated by the
    :envvar:`FLASK_DEBUG` environment variable. The default is ``False``.
    """
    val = os.environ.get("FLASK_DEBUG")
    return bool(val and val.lower() not in {"0", "false", "no"})


def get_load_dotenv(default: bool = True) -> bool:
    """Get whether the user has disabled loading default dotenv files by
    setting :envvar:`FLASK_SKIP_DOTENV`. The default is ``True``, load
    the files.

    :param default: What to return if the env var isn't set.
    """
    val = os.environ.get("FLASK_SKIP_DOTENV")

    if not val:
        return default

    return val.lower() in ("0", "false", "no")


@t.overload
def stream_with_context(
    generator_or_function: t.Iterator[t.AnyStr],
) -> t.Iterator[t.AnyStr]: ...


@t.overload
def stream_with_context(
    generator_or_function: t.Callable[..., t.Iterator[t.AnyStr]],
) -> t.Callable[[t.Iterator[t.AnyStr]], t.Iterator[t.AnyStr]]: ...

// ... (579 more lines)

Subdomains

Dependencies

Frequently Asked Questions

What does helpers.py do?
helpers.py is a source file in the flask codebase, written in python. It belongs to the ApplicationCore domain, Scaffolding subdomain.
What functions are defined in helpers.py?
helpers.py defines 16 function(s): _prepare_send_file_kwargs, _split_blueprint_path, abort, flash, get_debug_flag, get_flashed_messages, get_load_dotenv, get_root_path, get_template_attribute, make_response, and 6 more.
What does helpers.py depend on?
helpers.py imports 13 module(s): Response, datetime, functools, globals.py, importlib.util, os, signals.py, sys, and 5 more.
What files import helpers.py?
helpers.py is imported by 6 file(s): __init__.py, app.py, blueprints.py, cli.py, templating.py, wrappers.py.
Where is helpers.py in the architecture?
helpers.py is located at src/flask/helpers.py (domain: ApplicationCore, subdomain: Scaffolding, directory: src/flask).

Analyze Your Own Codebase

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

Try Supermodel Free