about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUltraQbik <no1skill@yandex.ru>2024-08-23 02:24:11 +0300
committerUltraQbik <no1skill@yandex.ru>2024-08-23 02:24:11 +0300
commitd9cc26c6a545e110615957890f36163dff4db7c0 (patch)
tree8bc4886cb220c668736107c6074e808d8cdb5a2c
parentec5d5d02798ee43aa0af1a26a170deaeb722e34f (diff)
downloadhttpy-d9cc26c6a545e110615957890f36163dff4db7c0.tar.gz
httpy-d9cc26c6a545e110615957890f36163dff4db7c0.zip
Change path map a bit
-rw-r--r--main.py49
1 files changed, 9 insertions, 40 deletions
diff --git a/main.py b/main.py
index 0b9f991..f68f6dd 100644
--- a/main.py
+++ b/main.py
@@ -13,36 +13,23 @@ from src import APIv1
 from src.socks import *
 from src.request import Request
 from src.minimizer import minimize_html
+from src.status_code import *
 
 
 # path mapping
 PATH_MAP = {
-    "/":
-        {"path": "www/index.html",
-         "compress": True},
-    "/index.html":
-        {"path": "www/index.html",
-         "compress": True},
-    "/robots.txt":
-        {"path": "www/robots.txt",
-         "compress": False},
-    "/favicon.ico":
-        {"path": "www/favicon.ico",
-         "compress": False},
-    "/css/styles.css":
-        {"path": "css/styles.css",
-         "compress": True},
-    "/about":
-        {"path": "www/about.html",
-         "compress": True},
-    "/test":
-        {"path": "www/test.html",
-         "compress": True},
+    "/":                    {"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"},
+    "/about":               {"path": "www/about.html"},
+    "/test":                {"path": "www/test.html"},
 }
 
 # API
 API_VERSIONS = {
-    "APIv1"
+    "APIv1":                {"supported": True}
 }
 
 # internal path map
@@ -51,24 +38,6 @@ I_PATH_MAP = {
 }
 
 
-def get_response_code(code: int) -> bytes:
-    match code:
-        case 200:
-            return b'200 OK'
-        case 400:
-            return b'400 Bad Request'
-        case 401:
-            return b'401 Unauthorized'
-        case 403:
-            return b'403 Forbidden'
-        case 404:
-            return b'404 Not Found'
-        case 6969:
-            return b'6969 UwU'
-        case _:  # in any other case return bad request response
-            return get_response_code(400)
-
-
 class HTTPServer:
     """
     The mighty HTTP server