As implied by the name, a request is a standardized message sent to an Endpoint requesting to obtain some resources. An example could be a request to obtain all the moviesβ names from IMDB database.
πππ There are multiple types of requests. Some of them are:
- POST
- GET
- DELETE
- UPDATE
- OPTIONS
- PUT
The names suggest what we can achieve when sending these requests.π
The most common ones are GET and POST.
GET | POST |
---|---|
request is visible β less secure | request is invisible β more secure |
the data that can be sent is limited | larger amounts of data can be sent |
same request β same response (is not supposed to change the state of the application) | same request β potentially different response (can change the state of the application) |
is used to get data | is used to send data and receive the result of the performed operation |
faster and more efficient, less secure | slowlier, more secure, can send more data of different types |
π How to
π Python
import requests
# GET request
r = requests.get("www.example.com/")
r = requests.get("www.example.com/message=mymessage") # when sending a message as # a key-value pair with "message" as a key and "mymessage" as a value
# POST request
r = requests.post("www.example.com", data={"message": "my message"})
βοΈ Resources:
- brief explanation ~1min
- longer explanation ~10min
- one more explanation ~7min
- [conceptual video explanation](https://youtu.be/RkGJ9tKI8s0](https://youtu.be/RkGJ9tKI8s0), ~2min