Starts the HTTP API on a separate thread. Returns: httpd: The HTTPServer instance. server_thread: The thread running the server.
(interaction_server, host='localhost', port=8000)
| 123 | |
| 124 | |
| 125 | def start_interaction_api(interaction_server, host='localhost', port=8000): |
| 126 | """ |
| 127 | Starts the HTTP API on a separate thread. |
| 128 | |
| 129 | Returns: |
| 130 | httpd: The HTTPServer instance. |
| 131 | server_thread: The thread running the server. |
| 132 | """ |
| 133 | httpd = HTTPServer((host, port), InteractionHandler) |
| 134 | httpd.interaction_server = interaction_server |
| 135 | def serve(): |
| 136 | print(f"Starting server on {host}:{port}") |
| 137 | httpd.serve_forever() |
| 138 | |
| 139 | server_thread = threading.Thread(target=serve, daemon=True) |
| 140 | server_thread.start() |
| 141 | return httpd, server_thread |
| 142 | |
| 143 | def stop_interaction_api(httpd): |
| 144 | """ |
no outgoing calls
no test coverage detected