diff options
| author | Qubik <89706156+UltraQbik@users.noreply.github.com> | 2024-08-23 20:27:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-23 20:27:27 +0200 |
| commit | 9aca00d7265b9d05f908b4201a03b7b0808c5ca1 (patch) | |
| tree | 47346be37cc68fc18aa8e5603eef58a48d9b2e04 /src/status_code.py | |
| parent | a96b13f6816ca0657d9f65097b97d0e87e1a0366 (diff) | |
| parent | fd8c46cac1c914851613cac425d2afe68d360d9d (diff) | |
| download | httpy-9aca00d7265b9d05f908b4201a03b7b0808c5ca1.tar.gz httpy-9aca00d7265b9d05f908b4201a03b7b0808c5ca1.zip | |
Merge pull request #2 from UltraQbik/threading-rewrite
Threading rewrite
Diffstat (limited to 'src/status_code.py')
| -rw-r--r-- | src/status_code.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/status_code.py b/src/status_code.py new file mode 100644 index 0000000..a63712c --- /dev/null +++ b/src/status_code.py @@ -0,0 +1,34 @@ +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") + + def __str__(self): + return f"{self._code} {self._message}" + + @property + def code(self): + return self._code + + @property + def message(self): + return self._message + + +# 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") |