Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import aiohttp
- import asyncio
- import async_timeout
- BASE_URL = 'http://localhost:8888'
- last_name = "Matvienko"
- first_name = "Aleksandr"
- user = {
- "email": "fantom0005@yandex.ru",
- "phone": "88005553535",
- "name": "%s %s Andreevich" % (last_name, first_name),
- "password": "qwerty123",
- "currency": "RUB"
- }
- async def fetch(url, json):
- session=aiohttp.ClientSession()
- async with session, asyncio.Semaphore(100), async_timeout.timeout(1500):
- print(f"Current URL {url}")
- try:
- async with session.post(url, json=json) as r:
- print(r.status)
- return await r.json()
- except aiohttp.client_exceptions.ClientConnectionError as e:
- print(e)
- return e
- except Exception as e:
- print(e)
- return e
- async def signup(user, session=aiohttp.ClientSession()):
- response = await fetch(f"{BASE_URL}/api/user/signup", user)
- print("asdasjofhaslfdasjnfldask")
- return response
- test = signup(user)
- print(test)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement