1
0
mirror of https://github.com/actix/examples synced 2024-11-28 00:12:57 +01:00
examples/json/client.py

21 lines
530 B
Python
Raw Normal View History

2018-07-29 16:36:43 +02:00
#!/usr/bin/env python3
# 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))
print(await resp.text())
assert 200 == resp.status
asyncio.get_event_loop().run_until_complete(req())