1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-12-04 23:36:34 +00:00
actix-web/examples/json/client.py

19 lines
506 B
Python
Raw Normal View History

2017-12-20 23:12:43 +00:00
# This script could be used for actix-web multipart example test
# just start server and run client.py
import json
import asyncio
import aiohttp
async def req():
resp = await aiohttp.ClientSession().request(
"post", 'http://localhost:8080/',
data=json.dumps({"name": "Test user", "number": 100}),
headers={"content-type": "application/json"})
print(str(resp))
2017-12-30 15:08:18 +00:00
print(await resp.text())
2017-12-20 23:12:43 +00:00
assert 200 == resp.status
asyncio.get_event_loop().run_until_complete(req())