Created
September 4, 2020 16:25
-
-
Save riccardodivirgilio/83025d11f706c546151c819e6640d69a to your computer and use it in GitHub Desktop.
Code for subzero-starter-kit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import asyncio | |
import websockets | |
import aiohttp | |
async def hello(): | |
async with aiohttp.ClientSession() as session: | |
async with session.post('http://localhost:8080/rest/rpc/login', data = {'email': 'alice@email.com', 'password': 'pass'}) as resp: | |
jwt = resp.headers['Set-Cookie'].split('=')[1].split(';')[0] | |
print(jwt) | |
async with session.post('http://localhost:8080/rest/todos', data = {'todo': 'item_something', 'private': False}) as resp: | |
print(resp) | |
print(await resp.text()) | |
async with session.get('http://localhost:8080/rest/todos') as resp: | |
print(resp) | |
print(len(await resp.json())) | |
asyncio.get_event_loop().run_until_complete(hello()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import asyncio | |
import websockets | |
import aiohttp | |
async def hello(): | |
async with aiohttp.ClientSession() as session: | |
async with session.post('http://localhost:8080/rest/rpc/login', data = {'email': 'alice@email.com', 'password': 'pass'}) as resp: | |
jwt = resp.headers['Set-Cookie'].split('=')[1].split(';')[0] | |
print(jwt) | |
async with session.post('http://localhost:8080/rabbitmq/auth/user', data = {'username': 'user_1', 'password': jwt}) as resp: | |
print(resp) | |
print(await resp.text()) | |
async with session.ws_connect("ws://localhost:8080/rabbitmq/ws") as ws: | |
async for msg in ws: | |
print(msg) | |
asyncio.get_event_loop().run_until_complete(hello()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment