(
connection: ServerConnection, request: Request
)
| 318 | |
| 319 | # HTTP handler — serves the host page and app HTML |
| 320 | def process_request( |
| 321 | connection: ServerConnection, request: Request |
| 322 | ) -> Response | None: |
| 323 | # Strip query string for path matching (?embedded=1 etc.) |
| 324 | path = request.path.split("?", 1)[0] |
| 325 | |
| 326 | if path == "/" or path == "": |
| 327 | return Response( |
| 328 | http.HTTPStatus.OK, |
| 329 | "OK", |
| 330 | websockets.Headers( |
| 331 | { |
| 332 | "Content-Type": "text/html; charset=utf-8", |
| 333 | "Content-Length": str(len(host_page_bytes)), |
| 334 | } |
| 335 | ), |
| 336 | host_page_bytes, |
| 337 | ) |
| 338 | if path == "/app": |
| 339 | return Response( |
| 340 | http.HTTPStatus.OK, |
| 341 | "OK", |
| 342 | websockets.Headers( |
| 343 | { |
| 344 | "Content-Type": "text/html; charset=utf-8", |
| 345 | "Content-Length": str(len(app_html_bytes)), |
| 346 | } |
| 347 | ), |
| 348 | app_html_bytes, |
| 349 | ) |
| 350 | if path != "/ws": |
| 351 | body = b"Not Found" |
| 352 | return Response( |
| 353 | http.HTTPStatus.NOT_FOUND, |
| 354 | "Not Found", |
| 355 | websockets.Headers({"Content-Length": str(len(body))}), |
| 356 | body, |
| 357 | ) |
| 358 | # Return None to proceed with WebSocket upgrade for /ws |
| 359 | return None |
| 360 | |
| 361 | # Store the initial tool result on the bridge so it is pushed |
| 362 | # only after the app sends ui/notifications/initialized. |
nothing calls this directly
no outgoing calls
no test coverage detected