quart.config module#

class quart.config.Config(root_path: str | PathLike, defaults: dict | None = None)#

Bases: Config

from_prefixed_env(prefix: str = 'QUART', *, loads: ~typing.Callable[[str], ~typing.Any] = <function loads>) bool#

Load any environment variables that start with the prefix.

The prefix (default QUART_) is dropped from the env key for the config key. Values are passed through a loading function to attempt to convert them to more specific types than strings.

Keys are loaded in sorted() order.

The default loading function attempts to parse values as any valid JSON type, including dicts and lists. Specific items in nested dicts can be set by separating the keys with double underscores (__). If an intermediate key doesn’t exist, it will be initialized to an empty dict.

  • prefix – Load env vars that start with this prefix, separated with an underscore (_).

  • loads – Pass each string value to this function and use the returned value as the config value. If any error is raised it is ignored and the value remains a string. The default is json.loads().