import aiohttp async def send_message(room: str, message: str) -> None: conn = aiohttp.UnixConnector(path='/tmp/test.sock') try: async with aiohttp.request('POST', 'http://localhost/', json={ 'type': 'message.text', 'room_id': room, 'message': message }, connector=conn) as resp: assert resp.status == 200 print(await resp.text()) finally: await conn.close()