Sobes.tech
Junior — Middle

Can you explain the meanings of the main HTTP status codes, such as 100, 200, 300, 400, and so on?

sobes.tech AI

Answer from AI

HTTP status codes are numerical codes that the server returns to the client to indicate the result of processing a request. Main categories of codes:

  • 1xx (Informational): For example, 100 Continue — the server has received the initial part of the request and the client can continue sending.
  • 2xx (Success): For example, 200 OK — the request was successfully processed, and the response contains the requested resource.
  • 3xx (Redirection): For example, 301 Moved Permanently — the resource has been moved to another URL, and the client should use the new address.
  • 4xx (Client errors): For example, 404 Not Found — the requested resource was not found, indicating an error on the client side.
  • 5xx (Server errors): For example, 500 Internal Server Error — an internal server error occurred while processing the request.

Example in Python using the requests library to check the response code:

import requests
response = requests.get('https://example.com')
print(response.status_code)  # Will output, for example, 200