diff options
| author | UltraQbik <no1skill@yandex.ru> | 2024-08-23 17:53:35 +0300 |
|---|---|---|
| committer | UltraQbik <no1skill@yandex.ru> | 2024-08-23 17:53:35 +0300 |
| commit | 19117444cf6362ee4aa6bdb8ef547daa91885265 (patch) | |
| tree | 1c56ac141befbc71fb4e0539209d99fc67f27c17 /main.py | |
| parent | c6a546b8677c512dc9ec4f48cea1d05dca266427 (diff) | |
| download | httpy-19117444cf6362ee4aa6bdb8ef547daa91885265.tar.gz httpy-19117444cf6362ee4aa6bdb8ef547daa91885265.zip | |
Add request handler method
Diffstat (limited to 'main.py')
| -rw-r--r-- | main.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/main.py b/main.py index 735e427..cbc2808 100644 --- a/main.py +++ b/main.py @@ -32,7 +32,7 @@ API_VERSIONS = { # internal path map I_PATH_MAP = { - "/err/response.html": {"path": "www/err/response.html"} + "/err/response": {"path": "www/err/response.html"} } @@ -101,7 +101,7 @@ class HTTPServer: def _client_thread(self, client: ssl.SSLSocket): """ - Handles client's requests + Handles getting client's requests :param client: client ssl socket """ @@ -113,8 +113,7 @@ class HTTPServer: if request is None: break - with open("www/index.html", "rb") as file: - send_response(client, file.read(), STATUS_CODE_OK) + threading.Thread(target=self._client_request_handler, args=[client, request], daemon=True).start() except TimeoutError: print("Client timeout") break @@ -125,6 +124,13 @@ class HTTPServer: # close the connection once stop even was set or an error occurred client.close() + def _client_request_handler(self, client, request): + """ + Handles responses to client's requests + :param client: client + :param request: client's request + """ + def _recv_request(self, client: ssl.SSLSocket) -> Request | None: """ Receive request from client |