diff options
| author | UltraQbik <no1skill@yandex.ru> | 2024-08-23 02:21:41 +0300 |
|---|---|---|
| committer | UltraQbik <no1skill@yandex.ru> | 2024-08-23 02:21:41 +0300 |
| commit | ec5d5d02798ee43aa0af1a26a170deaeb722e34f (patch) | |
| tree | dd55492cfa3fb50f7b0b6d2639243857d869bc5a /src | |
| parent | a96b13f6816ca0657d9f65097b97d0e87e1a0366 (diff) | |
| download | httpy-ec5d5d02798ee43aa0af1a26a170deaeb722e34f.tar.gz httpy-ec5d5d02798ee43aa0af1a26a170deaeb722e34f.zip | |
Add status codes
Diffstat (limited to 'src')
| -rw-r--r-- | src/status_code.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/status_code.py b/src/status_code.py new file mode 100644 index 0000000..e4b826b --- /dev/null +++ b/src/status_code.py @@ -0,0 +1,23 @@ +class StatusCode: + """ + HTML status code + """ + + def __init__(self, code: int, message: str): + self.code: int = code + self.message: str = message + + def __bytes__(self): + return f"{self.code} {self.message}".encode("ascii") + + +# Status codes! +STATUS_CODE_OK = StatusCode(200, "OK") +STATUS_CODE_BAD_REQUEST = StatusCode(400, "Bad Request") +STATUS_CODE_UNAUTHORIZED = StatusCode(401, "Unauthorized") +STATUS_CODE_FORBIDDEN = StatusCode(403, "Forbidden") +STATUS_CODE_NOT_FOUND = StatusCode(404, "Not Found") +STATUS_CODE_PAYLOAD_TOO_LARGE = StatusCode(413, "Payload Too Large") +STATUS_CODE_URI_TOO_LONG = StatusCode(414, "URI Too Long") +STATUS_CODE_IM_A_TEAPOT = StatusCode(418, "I'm a teapot") # I followed mozilla's dev page, it was there +STATUS_CODE_FUNNY_NUMBER = StatusCode(6969, "UwU") |