build_tools.syllable_walk_web.server

HTTP server for the Pipe-Works Build Tools web application.

Serves static frontend assets and provides a JSON API for pipeline and walker operations. Uses Python stdlib only (no frameworks).

Attributes

STATIC_DIR

AUTO_PORT_PRIMARY_START

AUTO_PORT_PRIMARY_TRIES

AUTO_PORT_FALLBACK_START

AUTO_PORT_FALLBACK_TRIES

Classes

CorpusBuilderHandler

HTTP request handler for the Corpus Builder web app.

Functions

find_available_port([start, max_tries])

Find an available port starting from start.

is_port_available(port)

Return True when a specific TCP port can be bound.

select_auto_port(*[, find_port])

Select an auto port by preferring the 8000-range first.

run_server([port, verbose, output_base, sessions_dir, ...])

Start the HTTP server.

Module Contents

build_tools.syllable_walk_web.server.STATIC_DIR
build_tools.syllable_walk_web.server.AUTO_PORT_PRIMARY_START = 8000
build_tools.syllable_walk_web.server.AUTO_PORT_PRIMARY_TRIES = 100
build_tools.syllable_walk_web.server.AUTO_PORT_FALLBACK_START = 8100
build_tools.syllable_walk_web.server.AUTO_PORT_FALLBACK_TRIES = 900
class build_tools.syllable_walk_web.server.CorpusBuilderHandler(request, client_address, server)[source]

Bases: http.server.BaseHTTPRequestHandler

HTTP request handler for the Corpus Builder web app.

Serves static files from the static/ directory and routes /api/* requests to the appropriate handlers.

server_version = 'PipeWorksCorpusBuilder/0.1'
verbose: bool = True
service_log_label: str = 'syllable-walk-web'
state: build_tools.syllable_walk_web.state.ServerState
do_GET()[source]

Handle GET requests.

do_POST()[source]

Handle POST requests.

log_message(format, *args)[source]

Override to respect verbose flag.

build_tools.syllable_walk_web.server.find_available_port(start=8000, max_tries=100)[source]

Find an available port starting from start.

Tries ports start through start + max_tries - 1. Returns the first available port, or None if none found.

build_tools.syllable_walk_web.server.is_port_available(port)[source]

Return True when a specific TCP port can be bound.

build_tools.syllable_walk_web.server.select_auto_port(*, find_port=find_available_port)[source]

Select an auto port by preferring the 8000-range first.

Checks 8000-8099 first, then falls back to 8100-8999.

build_tools.syllable_walk_web.server.run_server(port=None, verbose=True, output_base=None, sessions_dir=None, corpus_dir_a=None, corpus_dir_b=None)[source]

Start the HTTP server.

Parameters:
  • port (int | None) – Port to listen on. If None, checks 8000-8099 first, then 8100-8999.

  • verbose (bool) – If True, log HTTP requests to stderr.

  • output_base (pathlib.Path | None) – Base path for pipeline run discovery. Defaults to _working/output.

  • sessions_dir (pathlib.Path | None) – Optional explicit directory for saved walker sessions. Defaults to None (callers derive output_base/sessions).

  • corpus_dir_a (str | None) – Run discovery directory for Patch A.

  • corpus_dir_b (str | None) – Run discovery directory for Patch B.

Returns:

0 for clean shutdown, 1 for error.

Return type:

Exit code