Component: Networking¶
Canonical source:
SmrtApps/PythonApp/python_core/net/README.md(mirrored below)
python_core.net¶
Overview & Responsibilities¶
- Hosts the Python-side HTTP servers that connect SmrtHub WinUI surfaces, extensions, and automation agents to the Python Core runtime.
- Provides two primary surfaces:
bridge_serverfor WinUI↔Python interop andweb_listenerfor SmrtChrome metadata ingestion;wsgi.pysupplies the production entry point. - Centralizes route registration under
routes/so new endpoints ship in a consistent, testable pattern and stay aligned with documented policies.
Dependencies & Integrations¶
- Built on Flask plus Flasgger (Swagger docs) and Flask-CORS for extension telemetry; production deployments typically run behind
waitressor another WSGI host. - Reads canonical settings via
python_core.config.load_or_seed_bridge_settings()andload_or_seed_web_listener_settings(), keeping file locations compliant with the Operational Data Policy. - Relies on shared state helpers (
python_core.runtime,python_core.utils.shared_state_window, etc.) to fulfill requests and onpython_core.utils.logger.get_logger_for("python-net")for structured/text logging.
Runtime Flows / Operational Workflows¶
bridge_server.appregisters clipboard, hub window, trigger, structured-output, and status routes during module import; supervisors start it either via VS Code debugging or the deployment scripts underTools/.web_listener.appbootstraps CORS, exposes/tab-infoand/ping, and forwards tab metadata topython_core.smrtdetect.websource.handle_tab_info.wsgi.applicationhands the configured bridge app to WSGI servers; developers can runpython python_core/net/wsgi.pyfor a local Waitress host when debugging outside VS Code.
Configuration & Log Paths¶
- Bridge settings:
%APPDATA%/SmrtHub/Config/python-net/bridge-settings.json(seeded on demand). - Web listener settings:
%APPDATA%/SmrtHub/Config/python-net/web-listener-settings.json. - Logs land in
%LOCALAPPDATA%/SmrtHub/Logs/python-net/python-net-log.{txt,json}via the standard Smrt.Logging pipeline and are collected in Support Bundles.
Testing & Validation Expectations¶
- Execute
pytest -k net(or the full suite) after changing request handlers or dispatch logic. - Smoke-test HTTP surfaces by launching the PythonApp under the debugger and invoking representative routes (clipboard post, status get, SmrtSearch trigger) to confirm end-to-end wiring.
- For documentation or Swagger definition updates, rebuild the MkDocs set via the provided tasks when publishing user-facing manuals.
Support Bundle / Diagnostics Touchpoints¶
- Support Bundles capture the python-net logs and current bridge/web-listener settings; keep paths unchanged so exports remain accurate.
/statusexposes a lightweight health payload surfaced in diagnostics dashboards—preserve contract changes by documenting them here and in the associated docstrings.