Programming-Idioms

History of Idiom 183 > diff from v7 to v8

Edit summary for version 8 :
[Python] Add headers and data params as they are generally required for PUT requests.

Version 7

2019-09-26, 19:06:19

Version 8

2019-09-27, 19:11:23

Idiom #183 Make HTTP PUT request

Make a HTTP request with method PUT to URL u

Idiom #183 Make HTTP PUT request

Make a HTTP request with method PUT to URL u

Imports
requests
Imports
requests
Code
r = requests.put(u)
status_code, content = r.status_code, r.content
Code
import requests

content_type = 'text/plain'
headers = {'Content-Type': content_type}
data = {}

r = requests.put(url, headers=headers, data=data)
status_code, content = r.status_code, r.content
Doc URL
https://pypi.org/project/requests/
Doc URL
https://pypi.org/project/requests/
Origin
https://stackoverflow.com/questions/111945/is-there-any-way-to-do-http-put-in-python
Origin
https://stackoverflow.com/questions/111945/is-there-any-way-to-do-http-put-in-python
Demo URL
https://repl.it/repls/DizzyExaltedTests
Demo URL
https://repl.it/repls/DizzyExaltedTests