about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUltraQbik <no1skill@yandex.ru>2024-08-22 04:52:07 +0300
committerUltraQbik <no1skill@yandex.ru>2024-08-22 04:52:07 +0300
commit45680d00a4a8ed288d2a78baddb5e7c7e2e95cef (patch)
treee77424b1fe01bc935c993e357593946b9bd4216b
parent9a539001f3f1e77a6ea8332f659695d7ddcedb2f (diff)
downloadhttpy-45680d00a4a8ed288d2a78baddb5e7c7e2e95cef.tar.gz
httpy-45680d00a4a8ed288d2a78baddb5e7c7e2e95cef.zip
API seems to work
-rw-r--r--main.py5
-rw-r--r--src/APIv1.py8
2 files changed, 9 insertions, 4 deletions
diff --git a/main.py b/main.py
index dc80db6..0844fd7 100644
--- a/main.py
+++ b/main.py
@@ -216,6 +216,7 @@ class HTTPServer:
             # get API version
             api_version = request.path.split("/")[1]
 
+            data = b''
             match api_version:
                 case "APIv1":
                     status, data = await APIv1.respond(client, request)
@@ -225,6 +226,10 @@ class HTTPServer:
             # if status is not 200 -> send bad response
             if status != 200:
                 await HTTPServer._bad_response(client, status)
+                return
+
+            # send data if no error
+            await HTTPServer._send(client, status, data)
 
             # return after answer
             return
diff --git a/src/APIv1.py b/src/APIv1.py
index e0e4848..703c958 100644
--- a/src/APIv1.py
+++ b/src/APIv1.py
@@ -19,13 +19,13 @@ async def respond(client: SSLSocket, request: Request) -> tuple[int, bytes]:
     if api_level1 == "file":
         if api_level2 == "generated":
             if api_request == "1gib":
-                return 200, random.randbytes(2**30 * 1)
+                return 200, random.randbytes(1048576)
             elif api_request == "5gib":
-                return 200, random.randbytes(2**30 * 5)
+                return 200, random.randbytes(1048576)
             elif api_request == "10gib":
-                return 200, random.randbytes(2**30 * 10)
+                return 200, random.randbytes(1048576)
             elif api_request == "20gib":
-                return 200, random.randbytes(2**30 * 20)
+                return 200, random.randbytes(1048576)
             else:
                 return 400, b''
         else: