or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

authentication.mdcore-app.mdexceptions.mdindex.mdmcp.mdopenapi.mdrequest-response.mdstatus-codes.mdtemplating.mdwebsocket.md

status-codes.mddocs/

0

# HTTP Status Codes

1

2

Comprehensive HTTP status code constants for building robust web applications with proper response status handling.

3

4

## Capabilities

5

6

### Status Code Constants

7

8

HTTP status code constants following the IANA HTTP Status Code Registry, including informational, success, redirection, client error, and server error codes.

9

10

```python { .api }

11

# Informational responses (1xx)

12

HTTP_100_CONTINUE = 100

13

HTTP_101_SWITCHING_PROTOCOLS = 101

14

HTTP_102_PROCESSING = 102

15

HTTP_103_EARLY_HINTS = 103

16

17

# Successful responses (2xx)

18

HTTP_200_OK = 200

19

HTTP_201_CREATED = 201

20

HTTP_202_ACCEPTED = 202

21

HTTP_203_NON_AUTHORITATIVE_INFORMATION = 203

22

HTTP_204_NO_CONTENT = 204

23

HTTP_205_RESET_CONTENT = 205

24

HTTP_206_PARTIAL_CONTENT = 206

25

HTTP_207_MULTI_STATUS = 207

26

HTTP_208_ALREADY_REPORTED = 208

27

HTTP_226_IM_USED = 226

28

29

# Redirection messages (3xx)

30

HTTP_300_MULTIPLE_CHOICES = 300

31

HTTP_301_MOVED_PERMANENTLY = 301

32

HTTP_302_FOUND = 302

33

HTTP_303_SEE_OTHER = 303

34

HTTP_304_NOT_MODIFIED = 304

35

HTTP_305_USE_PROXY = 305

36

HTTP_306_RESERVED = 306

37

HTTP_307_TEMPORARY_REDIRECT = 307

38

HTTP_308_PERMANENT_REDIRECT = 308

39

40

# Client error responses (4xx)

41

HTTP_400_BAD_REQUEST = 400

42

HTTP_401_UNAUTHORIZED = 401

43

HTTP_402_PAYMENT_REQUIRED = 402

44

HTTP_403_FORBIDDEN = 403

45

HTTP_404_NOT_FOUND = 404

46

HTTP_405_METHOD_NOT_ALLOWED = 405

47

HTTP_406_NOT_ACCEPTABLE = 406

48

HTTP_407_PROXY_AUTHENTICATION_REQUIRED = 407

49

HTTP_408_REQUEST_TIMEOUT = 408

50

HTTP_409_CONFLICT = 409

51

HTTP_410_GONE = 410

52

HTTP_411_LENGTH_REQUIRED = 411

53

HTTP_412_PRECONDITION_FAILED = 412

54

HTTP_413_REQUEST_ENTITY_TOO_LARGE = 413

55

HTTP_414_REQUEST_URI_TOO_LONG = 414

56

HTTP_415_UNSUPPORTED_MEDIA_TYPE = 415

57

HTTP_416_REQUESTED_RANGE_NOT_SATISFIABLE = 416

58

HTTP_417_EXPECTATION_FAILED = 417

59

HTTP_418_IM_A_TEAPOT = 418

60

HTTP_421_MISDIRECTED_REQUEST = 421

61

HTTP_422_UNPROCESSABLE_ENTITY = 422

62

HTTP_423_LOCKED = 423

63

HTTP_424_FAILED_DEPENDENCY = 424

64

HTTP_425_TOO_EARLY = 425

65

HTTP_426_UPGRADE_REQUIRED = 426

66

HTTP_428_PRECONDITION_REQUIRED = 428

67

HTTP_429_TOO_MANY_REQUESTS = 429

68

HTTP_431_REQUEST_HEADER_FIELDS_TOO_LARGE = 431

69

HTTP_451_UNAVAILABLE_FOR_LEGAL_REASONS = 451

70

71

# Server error responses (5xx)

72

HTTP_500_INTERNAL_SERVER_ERROR = 500

73

HTTP_501_NOT_IMPLEMENTED = 501

74

HTTP_502_BAD_GATEWAY = 502

75

HTTP_503_SERVICE_UNAVAILABLE = 503

76

HTTP_504_GATEWAY_TIMEOUT = 504

77

HTTP_505_HTTP_VERSION_NOT_SUPPORTED = 505

78

HTTP_506_VARIANT_ALSO_NEGOTIATES = 506

79

HTTP_507_INSUFFICIENT_STORAGE = 507

80

HTTP_508_LOOP_DETECTED = 508

81

HTTP_510_NOT_EXTENDED = 510

82

HTTP_511_NETWORK_AUTHENTICATION_REQUIRED = 511

83

```

84

85

### Usage Examples

86

87

```python

88

from robyn import Robyn, status_codes, Response

89

90

app = Robyn(__file__)

91

92

@app.get("/")

93

def index(request):

94

return Response(

95

status_code=status_codes.HTTP_200_OK,

96

description="Hello, World!",

97

headers={}

98

)

99

100

@app.get("/created")

101

def created_resource(request):

102

return Response(

103

status_code=status_codes.HTTP_201_CREATED,

104

description="Resource created successfully",

105

headers={}

106

)

107

108

@app.get("/not-found")

109

def not_found(request):

110

return Response(

111

status_code=status_codes.HTTP_404_NOT_FOUND,

112

description="Resource not found",

113

headers={}

114

)

115

116

@app.get("/server-error")

117

def server_error(request):

118

return Response(

119

status_code=status_codes.HTTP_500_INTERNAL_SERVER_ERROR,

120

description="Internal server error",

121

headers={}

122

)

123

```