server

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

find_available_port([host, start, end])

Find the first available TCP port in start..end.

resolve_server_port(host, configured_port)

Resolve runtime port using manual config or auto-discovery.

create_handler_class(verbose, db_path, *, ...[, ...])

Create handler class bound to runtime verbosity and DB path.

start_http_server(settings)

Create a configured HTTPServer instance.

run_server(settings)

Run the server until interrupted.

create_argument_parser()

Create CLI argument parser for this server.

parse_arguments([argv])

Parse CLI arguments.

build_settings_from_args(args)

Build effective settings from INI config and CLI overrides.

main([argv])

CLI entrypoint for running this server.

Module Contents

server.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.

server.resolve_server_port(host, configured_port)

Resolve runtime port using manual config or auto-discovery.

Parameters:
  • host (str) – Bind host for availability checks.

  • configured_port (int | None) – 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.

Return type:

int

server.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.

server.start_http_server(settings)

Create a configured HTTPServer instance.

server.run_server(settings)

Run the server until interrupted.

Parameters:

settings (pipeworks_name_generation.webapp.config.ServerSettings) – Effective runtime settings from config and CLI overrides.

Returns:

Process-style exit code (0 on normal shutdown).

Return type:

int

server.create_argument_parser()

Create CLI argument parser for this server.

server.parse_arguments(argv=None)

Parse CLI arguments.

server.build_settings_from_args(args)

Build effective settings from INI config and CLI overrides.

server.main(argv=None)

CLI entrypoint for running this server.