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

Function main

python/examples/multipart.py:14–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

multipart.pyFile · 0.70

Calls 5

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

Tested by

no test coverage detected