MCPcopy Create free account
hub / github.com/0x676e67/wreq-python / main

Function main

python/examples/blocking/multipart.py:11–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9
10
11def main():
12 client = BlockingClient()
13 resp = client.post(
14 "https://httpbin.org/anything",
15 multipart=Multipart(
16 # Upload text data
17 Part(name="def", value="111", filename="def.txt", mime="text/plain"),
18 # Upload binary data
19 Part(name="abc", value=b"000", filename="abc.txt", mime="text/plain"),
20 # Unload file data
21 Part(
22 name="LICENSE",
23 value=Path("../../LICENSE"),
24 filename="LICENSE",
25 mime="text/plain",
26 ),
27 # Upload bytes stream file data
28 Part(
29 name="README",
30 value=file_to_bytes_stream("../../README.md"),
31 filename="README.md",
32 mime="text/plain",
33 ),
34 ),
35 )
36 print("Status Code: ", resp.status_code)
37 print("Version: ", resp.version)
38 print("Response URL: ", resp.url)
39 print("Headers: ", resp.headers)
40 print("Cookies: ", resp.cookies)
41 print("Content-Length: ", resp.content_length)
42 print("Encoding: ", resp.encoding)
43 print("Remote Address: ", resp.remote_addr)
44 print("Text: ", resp.text())
45
46
47if __name__ == "__main__":

Callers 1

multipart.pyFile · 0.70

Calls 6

postMethod · 0.95
BlockingClientClass · 0.85
MultipartClass · 0.85
PartClass · 0.85
file_to_bytes_streamFunction · 0.70
textMethod · 0.45

Tested by

no test coverage detected