mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-06 22:37:39 +03:00
add websocket example
This commit is contained in:
parent
1db4200621
commit
56c91adce2
13 changed files with 1120 additions and 85 deletions
32
examples/websocket/client.py
Normal file
32
examples/websocket/client.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
import asyncio
|
||||
import aiohttp
|
||||
|
||||
|
||||
def req1():
|
||||
with aiohttp.MultipartWriter() as writer:
|
||||
writer.append('test')
|
||||
writer.append_json({'passed': True})
|
||||
|
||||
resp = yield from aiohttp.request(
|
||||
"post", 'http://localhost:8080/multipart',
|
||||
data=writer, headers=writer.headers)
|
||||
print(resp)
|
||||
assert 200 == resp.status
|
||||
|
||||
|
||||
def req2():
|
||||
with aiohttp.MultipartWriter() as writer:
|
||||
writer.append('test')
|
||||
writer.append_json({'passed': True})
|
||||
writer.append(open('src/main.rs'))
|
||||
|
||||
resp = yield from aiohttp.request(
|
||||
"post", 'http://localhost:8080/multipart',
|
||||
data=writer, headers=writer.headers)
|
||||
print(resp)
|
||||
assert 200 == resp.status
|
||||
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(req1())
|
||||
loop.run_until_complete(req2())
|
Loading…
Add table
Add a link
Reference in a new issue