about summary refs log tree commit diff
path: root/src/status_code.py
blob: a63712cbcfcb6a9ba31c60ca0a7ceabacda4ba1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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")