Middle+
What are HTTP status codes? Name the main ones.
sobes.tech AI
Answer from AI
HTTP status codes are numerical codes that a server returns to a client in response to an HTTP request. They inform the client about the result of processing the request.
Main categories of status codes:
- 1xx (Informational): The request has been received, and the process is continuing (e.g., 100 Continue).
- 2xx (Success): The request was successfully processed (e.g., 200 OK, 201 Created).
- 3xx (Redirection): Additional action is needed to complete the request (e.g., 301 Moved Permanently, 302 Found).
- 4xx (Client Error): There was an error on the client side (e.g., 400 Bad Request, 401 Unauthorized, 404 Not Found).
- 5xx (Server Error): There was an error on the server side (e.g., 500 Internal Server Error, 503 Service Unavailable).
Example of usage in Python with the requests library:
import requests
response = requests.get('https://example.com')
print(response.status_code) # Will output, for example, 200