I have a sample curl command here to post a file to REST based API. my understanding is that, -F flag is used for multipart/form-data HTTP request and is required to upload a file(s).
curl -X POST -F "image=@/path/to/your/image" https://abc.example.com/v1/....
I have used python requests library to make HTTP calls as such , mostly a dictonary objects , serialized as json . essentially text data.
my question is how do i post a file , with python requests library? how does the HTTP call work with the files vs just sending text data as below? I'm learning web development so would help out with my understanding , how it works behind the scenes.
import requestsurl = 'https://www.example.com/...'data= {'key': 'value'}x = requests.post(url, json = data)print(x.text)