Junior — Middle
Can you explain what an HTTP GET request means and what it is used for?
sobes.tech AI
Answer from AI
An HTTP GET request is one of the main methods of the HTTP protocol, used to request data from a server. It is designed to retrieve a resource at the specified URL without changing the server's state.
GET requests are typically used to retrieve web pages, images, API data, etc. An important feature is that request parameters are passed in the URL (via the query string), and the request should have no side effects.
Example of a GET request using Python and the requests library:
import requests
response = requests.get('https://api.example.com/data?item=123')
print(response.status_code)
print(response.text)
Here, we request data from the server and print the response status and body.