config

Configuration loading for the end-user name generator web application.

The application supports a small INI file so end users can set runtime values without changing Python code. The most important setting is port; when it is omitted the server auto-selects a free port in the 8000 range.

The canonical INI section name is [webapp]. For backward compatibility, [server] is accepted as a fallback when [webapp] is not present.

Attributes

DEFAULT_HOST

DEFAULT_DB_PATH

DEFAULT_FAVORITES_DB_PATH

DEFAULT_DB_EXPORT_PATH

DEFAULT_DB_BACKUP_PATH

Classes

ServerSettings

Server runtime settings.

Functions

load_server_settings(config_path)

Load server settings from an INI file.

apply_runtime_overrides(settings, host, port, db_path, ...)

Apply command-line overrides over loaded settings.

Module Contents

config.DEFAULT_HOST = '127.0.0.1'
config.DEFAULT_DB_PATH
config.DEFAULT_FAVORITES_DB_PATH
config.DEFAULT_DB_EXPORT_PATH: pathlib.Path | None = None
config.DEFAULT_DB_BACKUP_PATH: pathlib.Path | None = None
class config.ServerSettings

Server runtime settings.

host

Interface to bind (default localhost)

port

Optional explicit port. None means auto-select.

db_path

SQLite database file path

favorites_db_path

SQLite database file path for user favorites

verbose

Print startup/runtime messages when True

serve_ui

When True, serve UI/static routes in addition to the API.

host: str = '127.0.0.1'
port: int | None = None
db_path: pathlib.Path
favorites_db_path: pathlib.Path
db_export_path: pathlib.Path | None = None
db_backup_path: pathlib.Path | None = None
verbose: bool = True
serve_ui: bool = True
config.load_server_settings(config_path)

Load server settings from an INI file.

The parser reads a [webapp] section (preferred) or [server] section (backward-compatible fallback) with the following optional keys: host, port, db_path, favorites_db_path, verbose, and serve_ui. An optional api_only flag can be used to force API-only mode and overrides serve_ui when set.

Parameters:

config_path (pathlib.Path | None) – Path to INI file. If missing/None, defaults are used.

Returns:

Parsed ServerSettings instance

Raises:

ValueError – If a setting is syntactically invalid

Return type:

ServerSettings

config.apply_runtime_overrides(settings, host, port, db_path, favorites_db_path, db_export_path, db_backup_path, verbose, serve_ui)

Apply command-line overrides over loaded settings.

Parameters:
  • settings (ServerSettings) – Base settings (typically from INI)

  • host (str | None) – Optional host override

  • port (int | None) – Optional port override

  • db_path (pathlib.Path | None) – Optional database path override

  • favorites_db_path (pathlib.Path | None) – Optional favorites database path override

  • verbose (bool | None) – Optional verbose override

  • serve_ui (bool | None) – Optional UI routing override

Returns:

Updated settings with overrides applied

Return type:

ServerSettings