Skip to content

Instantly share code, notes, and snippets.

@Tarequzzaman
Created March 6, 2021 17:39
Show Gist options
  • Save Tarequzzaman/bf9b7436b0566a6148904353aaf1f30b to your computer and use it in GitHub Desktop.
Save Tarequzzaman/bf9b7436b0566a6148904353aaf1f30b to your computer and use it in GitHub Desktop.
async post request python
import aiohttp
async def call_url(session):
url = "http://127.0.0.1:5005/webhooks/rest/webhook"
data = '{"sender":"218311","message":"english"}'
response = await session.post(url=url, data=data)
return response
# async def call_with_aiohttp():
async with aiohttp.ClientSession() as session:
x = await call_url(session)
if x.status == 200:
y= await x.json()
print(y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment