config ====== .. py:module:: config .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: config.DEFAULT_HOST config.DEFAULT_DB_PATH config.DEFAULT_FAVORITES_DB_PATH config.DEFAULT_DB_EXPORT_PATH config.DEFAULT_DB_BACKUP_PATH Classes ------- .. autoapisummary:: config.ServerSettings Functions --------- .. autoapisummary:: config.load_server_settings config.apply_runtime_overrides Module Contents --------------- .. py:data:: DEFAULT_HOST :value: '127.0.0.1' .. py:data:: DEFAULT_DB_PATH .. py:data:: DEFAULT_FAVORITES_DB_PATH .. py:data:: DEFAULT_DB_EXPORT_PATH :type: pathlib.Path | None :value: None .. py:data:: DEFAULT_DB_BACKUP_PATH :type: pathlib.Path | None :value: None .. py:class:: ServerSettings Server runtime settings. .. attribute:: host Interface to bind (default localhost) .. attribute:: port Optional explicit port. ``None`` means auto-select. .. attribute:: db_path SQLite database file path .. attribute:: favorites_db_path SQLite database file path for user favorites .. attribute:: verbose Print startup/runtime messages when True .. attribute:: serve_ui When ``True``, serve UI/static routes in addition to the API. .. py:attribute:: host :type: str :value: '127.0.0.1' .. py:attribute:: port :type: int | None :value: None .. py:attribute:: db_path :type: pathlib.Path .. py:attribute:: favorites_db_path :type: pathlib.Path .. py:attribute:: db_export_path :type: pathlib.Path | None :value: None .. py:attribute:: db_backup_path :type: pathlib.Path | None :value: None .. py:attribute:: verbose :type: bool :value: True .. py:attribute:: serve_ui :type: bool :value: True .. py:function:: 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. :param config_path: Path to INI file. If missing/None, defaults are used. :returns: Parsed ``ServerSettings`` instance :raises ValueError: If a setting is syntactically invalid .. py:function:: 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. :param settings: Base settings (typically from INI) :param host: Optional host override :param port: Optional port override :param db_path: Optional database path override :param favorites_db_path: Optional favorites database path override :param verbose: Optional verbose override :param serve_ui: Optional UI routing override :returns: Updated settings with overrides applied