コード例 #1
0
requests.init_client()

print(requests.get("http://httpbin.org/get"))  # HTTP GET.

print(
    requests.post("http://httpbin.org/post",
                  """{"foo": "bar", "baz": true}"""))  # HTTP POST.

print(requests.put("http://httpbin.org/put",
                   """{"foo": "bar", "baz": true}"""))  # HTTP PUT.

print(requests.delete("http://httpbin.org/delete"))  # HTTP DELETE.

print(
    requests.patch("http://httpbin.org/patch",
                   """{"foo": "bar", "baz": true}"""))  # HTTP PATCH.

print(requests.get2str(
    "http://httpbin.org/get"))  # HTTP GET body only to string response.

print(requests.get2dict(
    "http://httpbin.org/get"))  # HTTP GET body only to dictionary response.

print(requests.get2json(
    "http://httpbin.org/get"))  # HTTP GET body only to JSON response.

print(
    requests.post2str("http://httpbin.org/post",
                      """{"foo": "bar", "baz": true}""")
)  # HTTP POST data only to string response.
コード例 #2
0
ファイル: tests.py プロジェクト: zzzdtz/faster-than-requests
 def test_patch(self):
     self.assertIsInstance(faster_than_requests.patch("http://httpbin.org/patch", """{"foo": "bar", "baz": true}"""), dict)