server ====== .. py:module:: server .. autoapi-nested-parse:: Simple web server with Import, Generation, and Database View tabs. This version stores package imports in SQLite and creates one SQLite data table for each imported ``*.txt`` selection file. JSON files are intentionally ignored for now, per current requirements. Functions --------- .. autoapisummary:: server.find_available_port server.resolve_server_port server.create_handler_class server.start_http_server server.run_server server.create_argument_parser server.parse_arguments server.build_settings_from_args server.main Module Contents --------------- .. py:function:: find_available_port(host = '127.0.0.1', start = 8000, end = 8999) Find the first available TCP port in ``start..end``. :raises OSError: When no free port is available in the given range. .. py:function:: resolve_server_port(host, configured_port) Resolve runtime port using manual config or auto-discovery. :param host: Bind host for availability checks. :param configured_port: Optional explicit port from config/CLI. :returns: Concrete port to bind. :raises OSError: If a configured port is unavailable or no auto port is free. .. py:function:: create_handler_class(verbose, db_path, *, favorites_db_path, serve_ui, db_export_path = None, db_backup_path = None) Create handler class bound to runtime verbosity and DB path. The runtime bootstrap initializes schema before creating the handler class, so ``schema_ready`` is set to ``True`` to skip per-request schema checks on the hot path. Route maps are selected based on ``serve_ui`` so API-only deployments skip UI/static endpoints entirely. .. py:function:: start_http_server(settings) Create a configured ``HTTPServer`` instance. .. py:function:: run_server(settings) Run the server until interrupted. :param settings: Effective runtime settings from config and CLI overrides. :returns: Process-style exit code (``0`` on normal shutdown). .. py:function:: create_argument_parser() Create CLI argument parser for this server. .. py:function:: parse_arguments(argv = None) Parse CLI arguments. .. py:function:: build_settings_from_args(args) Build effective settings from INI config and CLI overrides. .. py:function:: main(argv = None) CLI entrypoint for running this server.