- Python Falcon - Discussion
- Python Falcon - Useful Resources
- Python Falcon - Quick Guide
- Python Falcon - Deployment
- Python Falcon - Testing
- Python Falcon - Sqlalchemy Models
- Python Falcon - Websocket
- Python Falcon - CORS
- Python Falcon - Middleware
- Python Falcon - Hooks
- Python Falcon - Error Handling
- Python Falcon - Status Codes
- Python Falcon - Cookies
- Python Falcon - Jinja2 Template
- Python Falcon - Inspect Module
- Falcon - Suffixed Responders
- Python Falcon - Routing
- Python Falcon - App Class
- Python Falcon - Resource Class
- Request & Response
- Python Falcon - API Testing Tools
- Python Falcon - Uvicorn
- Python Falcon - ASGI
- Python Falcon - Waitress
- Python Falcon - Hello World(WSGI)
- Python Falcon - WSGI vs ASGI
- Python Falcon - Environment Setup
- Python Falcon - Introduction
- Python Falcon - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Python Falcon - Status Codes
By default, the HTTP server s response to a cpent s request is having 200 OK status. Falcon provides its own pst of status constant for more convenience and readabipty.
For example, 200 OK status code is represented by,
resp.status = falcon.HTTP_OK
These predefined Falcon constants avoid typos and cuts down on the number of string objects that must be created when preparing responses. However, starting with Falcon version 3.0, using bare int codes is allowed as well.
resp.status = 200
For ASGI apppcation, same status codes are apppcable.
Some of the status codes defined in Falcon pbrary are psted below −
Informational Codes
HTTP_CONTINUE = HTTP_100
HTTP_SWITCHING_PROTOCOLS = HTTP_101
HTTP_PROCESSING = HTTP_102
Success Status Codes
HTTP_OK = HTTP_200
HTTP_CREATED = HTTP_201
HTTP_ACCEPTED = HTTP_202
HTTP_NON_AUTHORITATIVE_INFORMATION = HTTP_203
HTTP_NO_CONTENT = HTTP_204
HTTP_RESET_CONTENT = HTTP_205
HTTP_PARTIAL_CONTENT = HTTP_206
HTTP_MULTI_STATUS = HTTP_207
HTTP_ALREADY_REPORTED = HTTP_208
HTTP_IM_USED = HTTP_226
Redirection Error Codes
HTTP_MULTIPLE_CHOICES = HTTP_300
HTTP_MOVED_PERMANENTLY = HTTP_301
HTTP_FOUND = HTTP_302
HTTP_SEE_OTHER = HTTP_303
HTTP_NOT_MODIFIED = HTTP_304
HTTP_USE_PROXY = HTTP_305
HTTP_TEMPORARY_REDIRECT = HTTP_307
HTTP_PERMANENT_REDIRECT = HTTP_308
Cpent Error Codes
HTTP_BAD_REQUEST = HTTP_400
HTTP_UNAUTHORIZED = HTTP_401 # "unauthenticated"
HTTP_PAYMENT_REQUIRED = HTTP_402
HTTP_FORBIDDEN = HTTP_403 # "unauthorized"
HTTP_NOT_FOUND = HTTP_404
HTTP_METHOD_NOT_ALLOWED = HTTP_405
HTTP_NOT_ACCEPTABLE = HTTP_406
HTTP_PROXY_AUTHENTICATION_REQUIRED = HTTP_407
HTTP_REQUEST_TIMEOUT = HTTP_408
HTTP_CONFLICT = HTTP_409
Server Error Codes
HTTP_INTERNAL_SERVER_ERROR = HTTP_500
HTTP_NOT_IMPLEMENTED = HTTP_501
HTTP_BAD_GATEWAY = HTTP_502
HTTP_SERVICE_UNAVAILABLE = HTTP_503
HTTP_GATEWAY_TIMEOUT = HTTP_504
HTTP_HTTP_VERSION_NOT_SUPPORTED = HTTP_505
HTTP_INSUFFICIENT_STORAGE = HTTP_507
HTTP_LOOP_DETECTED = HTTP_508
HTTP_NETWORK_AUTHENTICATION_REQUIRED = HTTP_511