settings

Application settings

Application settings.

Secrets are consumed from env vars.

class app.config.settings.ViteSettings(DEV_MODE: bool = <factory>, USE_SERVER_LIFESPAN: bool = <factory>, HOST: str = <factory>, PORT: int = <factory>, HOT_RELOAD: bool = <factory>, ENABLE_REACT_HELPERS: bool = <factory>, BUNDLE_DIR: ~pathlib.Path = <factory>, RESOURCE_DIR: ~pathlib.Path = <factory>, TEMPLATE_DIR: ~pathlib.Path = <factory>, ASSET_URL: str = <factory>)[source]

Bases: object

Server configurations.

DEV_MODE: bool

Start vite development server.

USE_SERVER_LIFESPAN: bool

Auto start and stop vite processes when running in development mode..

HOST: str

The host the vite process will listen on. Defaults to 0.0.0.0

PORT: int

The port to start vite on. Default to 5173

HOT_RELOAD: bool

Start vite with HMR enabled.

ENABLE_REACT_HELPERS: bool

Enable React support in HMR.

BUNDLE_DIR: Path

Bundle directory

RESOURCE_DIR: Path

Resource directory

TEMPLATE_DIR: Path

Template directory.

ASSET_URL: str

Base URL for assets

property set_static_files: bool

Serve static assets.

Returns:

True if the asset URL is a relative path.

Return type:

bool

__init__(DEV_MODE: bool = <factory>, USE_SERVER_LIFESPAN: bool = <factory>, HOST: str = <factory>, PORT: int = <factory>, HOT_RELOAD: bool = <factory>, ENABLE_REACT_HELPERS: bool = <factory>, BUNDLE_DIR: ~pathlib.Path = <factory>, RESOURCE_DIR: ~pathlib.Path = <factory>, TEMPLATE_DIR: ~pathlib.Path = <factory>, ASSET_URL: str = <factory>) None
class app.config.settings.ServerSettings(APP_LOC: str = 'app.asgi:app', APP_LOC_IS_FACTORY: bool = False, HOST: str = <factory>, PORT: int = <factory>, KEEPALIVE: int = <factory>, RELOAD: bool = <factory>, RELOAD_DIRS: list[str] = <factory>, HTTP_WORKERS: int | None = <factory>)[source]

Bases: object

Server configurations.

APP_LOC: str = 'app.asgi:app'

Path to app executable, or factory.

APP_LOC_IS_FACTORY: bool = False

Indicate if APP_LOC points to an executable or factory.

HOST: str

Server network host.

PORT: int

Server port.

KEEPALIVE: int

Seconds to hold connections open (65 is > AWS lb idle timeout).

RELOAD: bool

Turn on hot reloading.

RELOAD_DIRS: list[str]

Directories to watch for reloading.

HTTP_WORKERS: int | None

Number of HTTP Worker processes to be spawned by Uvicorn.

__init__(APP_LOC: str = 'app.asgi:app', APP_LOC_IS_FACTORY: bool = False, HOST: str = <factory>, PORT: int = <factory>, KEEPALIVE: int = <factory>, RELOAD: bool = <factory>, RELOAD_DIRS: list[str] = <factory>, HTTP_WORKERS: int | None = <factory>) None
class app.config.settings.LogSettings(EXCLUDE_PATHS: str = '\\A(?!x)x', HTTP_EVENT: str = 'HTTP', INCLUDE_COMPRESSED_BODY: bool = False, LEVEL: int = <factory>, OBFUSCATE_COOKIES: set[str] = <factory>, OBFUSCATE_HEADERS: set[str] = <factory>, REQUEST_FIELDS: list[RequestExtractorField] = <factory>, RESPONSE_FIELDS: list[ResponseExtractorField] = <factory>, GRANIAN_ACCESS_LEVEL: int = 30, GRANIAN_ERROR_LEVEL: int = 20)[source]

Bases: object

Logger configuration.

EXCLUDE_PATHS: str = '\\A(?!x)x'

Regex to exclude paths from logging.

HTTP_EVENT: str = 'HTTP'

Log event name for logs from Litestar handlers.

INCLUDE_COMPRESSED_BODY: bool = False

Include body of compressed responses in log output.

__init__(EXCLUDE_PATHS: str = '\\A(?!x)x', HTTP_EVENT: str = 'HTTP', INCLUDE_COMPRESSED_BODY: bool = False, LEVEL: int = <factory>, OBFUSCATE_COOKIES: set[str] = <factory>, OBFUSCATE_HEADERS: set[str] = <factory>, REQUEST_FIELDS: list[RequestExtractorField] = <factory>, RESPONSE_FIELDS: list[ResponseExtractorField] = <factory>, GRANIAN_ACCESS_LEVEL: int = 30, GRANIAN_ERROR_LEVEL: int = 20) None
LEVEL: int

Stdlib log levels.

Only emit logs at this level, or higher.

OBFUSCATE_COOKIES: set[str]

Request cookie keys to obfuscate.

OBFUSCATE_HEADERS: set[str]

Request header keys to obfuscate.

REQUEST_FIELDS: list[RequestExtractorField]

Attributes of the `~litestar.connection.request.Request`_ to be logged.

RESPONSE_FIELDS: list[ResponseExtractorField]

Attributes of the `~litestar.response.Response`_ to be logged.

GRANIAN_ACCESS_LEVEL: int = 30

Level to log uvicorn access logs.

GRANIAN_ERROR_LEVEL: int = 20

Level to log uvicorn error logs.

class app.config.settings.AppSettings(URL: str = <factory>, DEBUG: bool = <factory>, SECRET_KEY: str = <factory>, NAME: str = <factory>)[source]

Bases: object

Application configuration.

__init__(URL: str = <factory>, DEBUG: bool = <factory>, SECRET_KEY: str = <factory>, NAME: str = <factory>) None
URL: str

The frontend base URL

DEBUG: bool

Run Litestar with debug=True.

SECRET_KEY: str

Application secret key.

NAME: str

Application name.

class app.config.settings.TemplateSettings(ENGINE: type[~litestar.contrib.jinja.JinjaTemplateEngine] = <class 'litestar.contrib.jinja.JinjaTemplateEngine'>)[source]

Bases: object

Configures Templating for the project.

__init__(ENGINE: type[~litestar.contrib.jinja.JinjaTemplateEngine] = <class 'litestar.contrib.jinja.JinjaTemplateEngine'>) None
ENGINE

Template engine to use. (Jinja2 or Mako)

alias of JinjaTemplateEngine

class app.config.settings.Settings(app: ~app.config.settings.AppSettings = <factory>, template: ~app.config.settings.TemplateSettings = <factory>, vite: ~app.config.settings.ViteSettings = <factory>, server: ~app.config.settings.ServerSettings = <factory>, log: ~app.config.settings.LogSettings = <factory>)[source]

Bases: object

Application settings.

__init__(app: ~app.config.settings.AppSettings = <factory>, template: ~app.config.settings.TemplateSettings = <factory>, vite: ~app.config.settings.ViteSettings = <factory>, server: ~app.config.settings.ServerSettings = <factory>, log: ~app.config.settings.LogSettings = <factory>) None
classmethod from_env(dotenv_filename: str = '.env') Settings[source]

Load settings from environment variables.

Parameters:

dotenv_filename (str) – The name of the dotenv file to load. Assumes curdir but can pass the rest of the path.

Returns:

Application settings

Return type:

Settings

app.config.settings.get_settings() Settings[source]

Helper function to get settings from elsewhere.

Returns:

Application settings

Return type:

Settings