Send multiple requests using 3 lines of code!
Project description
MultiGather
You can install package by:
pip install MultiGather
Simple example for POST:
import asyncio
from MultiGather import Client
from MultiGather.Types import Config, Request
# Replace with the actual URL for your POST endpoint
url = "https://your-api-endpoint/posts"
# Replace with the data you want to send in the POST request
data = {"title": "New Post", "body": "This is a sample post content", "userId": 1}
async def main():
client = Client.Connection(Config(timeout=10)) # Set timeout to 10 seconds (optional)
# Prepare a POST request object
post_request = Request(method="POST", url=url, json=data, amount=5) ## gonna send 5 requests
# Send the requests asynchronously and collect responses
responses = await client.sendRequest(post_request)
# Print the status code for each response
for response in responses:
print(f"POST response status: {response.status}")
asyncio.run(main())
Simple example for GET:
import asyncio
from MultiGather import Client
from MultiGather.Types import Config, Request
# Replace with the actual URL for your GET endpoint
url = "https://your-api-endpoint/posts"
async def main():
client = Client.Connection(Config(timeout=10)) # Set timeout to 10 seconds (optional)
# Prepare a GET request object
get_request = Request(method="GET", url=url, amount=5) # send 5 requests.
# Send the requests asynchronously and collect responses
responses = await client.sendRequest(get_request)
# Print the status code for each response
for response in responses:
print(f"GET response status: {response.status}")
asyncio.run(main())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
multigather-0.0.5.tar.gz
(2.7 kB
view hashes)
Built Distribution
Close
Hashes for MultiGather-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 116122828283a243ea715d79e5161b67d8b7d026ac5fbe0a0dbd4cd8e2785970 |
|
MD5 | 79e8b4a2b2010e1d03e2290ccf2666f3 |
|
BLAKE2b-256 | 0e32d98e61661d7a1b2082fed5642c91a7072a276250dc5aa8f3c6d0fb794d26 |