Skip to content

Instantly share code, notes, and snippets.

@riccardodivirgilio
Created September 4, 2020 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riccardodivirgilio/83025d11f706c546151c819e6640d69a to your computer and use it in GitHub Desktop.
Save riccardodivirgilio/83025d11f706c546151c819e6640d69a to your computer and use it in GitHub Desktop.
Code for subzero-starter-kit
#!/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())
#!/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