def from_envvars(conf, prefix=None, envvars=None, as_json=True):
    if prefix is None and envvars is None:
        raise RuntimeError('Must either give prefix or envvars argument')

    # if it's a list, convert to dict
    if isinstance(envvars, list):
        envvars = {k: None for k in envvars}

    if not envvars:
        envvars = {k: k[len(prefix):] for k in os.environ.keys()
                   if k.startswith(prefix)}

    for env_name, name in envvars.items():
        if name is None:
            name = env_name

        if not env_name in os.environ:
            continue

        if as_json:
            try:
                conf[name] = json.loads(os.environ[env_name])
            except ValueError:
                conf[name] = os.environ[env_name]
        else:
            conf[name] = os.environ[env_name]
Load environment variables as Flask configuration settings.
dataset/ETHPy150Open mbr/flask-appconfig/flask_appconfig/env.py/from_envvars