master
Родитель
cc792ebc3c
Сommit
e0b7f9de12
@ -0,0 +1,45 @@
|
|||||||
|
import requests
|
||||||
|
|
||||||
|
# GET
|
||||||
|
payload = {'key1': 'value1', 'key2': 'value2'}
|
||||||
|
response = requests.get(
|
||||||
|
'https://api.github.com/',
|
||||||
|
params=payload
|
||||||
|
)
|
||||||
|
|
||||||
|
print("Status Code", response.status_code)
|
||||||
|
print("Response content ", response.text)
|
||||||
|
|
||||||
|
# POST
|
||||||
|
payload = {
|
||||||
|
"id": 1001,
|
||||||
|
"name": "geek",
|
||||||
|
"passion": "coding",
|
||||||
|
}
|
||||||
|
|
||||||
|
response = requests.post(
|
||||||
|
'https://httpbin.org/post',
|
||||||
|
json=payload)
|
||||||
|
|
||||||
|
print("Status Code", response.status_code)
|
||||||
|
print("JSON Response ", response.json())
|
||||||
|
|
||||||
|
|
||||||
|
# DELETE not allowed
|
||||||
|
|
||||||
|
|
||||||
|
# POST
|
||||||
|
payload = {
|
||||||
|
"id": 1001,
|
||||||
|
"name": "geek",
|
||||||
|
"passion": "coding",
|
||||||
|
}
|
||||||
|
|
||||||
|
response = requests.delete(
|
||||||
|
'https://httpbin.org/post',
|
||||||
|
json=payload)
|
||||||
|
|
||||||
|
print("Status Code", response.status_code)
|
||||||
|
print("JSON Response ", response.json())
|
||||||
|
|
||||||
|
|
Двоичный файл не отображается.
Двоичный файл не отображается.
Загрузка…
Ссылка в новой задаче