about summary refs log tree commit diff
path: root/main.py
diff options
context:
space:
mode:
authorUltraQbik <no1skill@yandex.ru>2024-08-20 17:04:22 +0300
committerUltraQbik <no1skill@yandex.ru>2024-08-20 17:04:22 +0300
commitd733e209619e544f74a6e933dbe367e9a48fc62b (patch)
treefced586cc7c4c08cd51790e188e4464b4aac6a38 /main.py
parent925a5592a1475030e1bf08d139bd9364ee9f6dbe (diff)
downloadhttpy-d733e209619e544f74a6e933dbe367e9a48fc62b.tar.gz
httpy-d733e209619e544f74a6e933dbe367e9a48fc62b.zip
Path mapping and get requests start
Diffstat (limited to 'main.py')
-rw-r--r--main.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/main.py b/main.py
index 7889ef8..013d410 100644
--- a/main.py
+++ b/main.py
@@ -13,6 +13,16 @@ import aiofiles
 import threading
 
 
+# path mapping
+PATH_MAP = {
+    "/":                        {"path": "www/index.html"},
+    "/index.html":              {"path": "www/index.html"},
+    "/robots.txt":              {"path": "www/robots.txt"},
+    "/favicon.ico":             {"path": "www/favicon.ico"},
+    "/css/styles.css":          {"path": "css/styles.css"},
+}
+
+
 class Request:
     """
     Just a request
@@ -115,9 +125,26 @@ class HTTPServer:
             # decode request
             request: Request = Request.create(raw_request)
 
+            # handle requests
+            match request.type:
+                case "GET":
+                    await self.handle_get_request(client, request)
+                case _:
+                    pass
+
             self._close_client(client)
             break
 
+    @staticmethod
+    async def handle_get_request(client: socket.socket, request: Request):
+        """
+        Handles user's GET request
+        :param client: client
+        :param request: client's request
+        """
+
+        pass
+
     def _close_client(self, client: socket.socket):
         """
         Closes a client