def env_flag(env_var, default=False):
    """
    Return the specified environment variable coerced to a bool, as follows:

    - When the variable is unset, or set to the empty string, return `default`.
    - When the variable is set to a truthy value, returns `True`.
      These are the truthy values:
          - 1
          - true, yes, on
    - When the variable is set to the anything else, returns False.
       Example falsy values:
          - 0
          - no
    - Ignore case and leading/trailing whitespace.
    """
    import os
    environ_string = os.environ.get(env_var, '').strip().lower()
    if not environ_string:
        return default
    return environ_string in ['1', 'true', 'yes', 'on']
