Mopidy Websocket Connection with Flask

Hi all,
I’m trying to create my own simple mopidy web client using the websocket API.
So far I’m running a flask server with a python script which already uses as a websocket for general purpose. I now want to simply connect from within this python script to ws://localhost:6680/mopidy/ws to send and receive messages.
Since I am relatively new to webdevelopment the documentation is not sufficient for me. I even tried the module “websockets” instead of “” but unfortunately without success too.
Does anyone have a simple example on how to connect to mopidy ws interface through a python script?

For example I tried following code within my python script:

import asyncio
import websockets

async def test():
uri = “ws://localhost:6680/mopidy/ws”
async with websockets.connect(uri) as websocket:
await websocket.send(’{“jsonrpc”: “2.0”, “id”: 1, “method”: “core.get_version()”}’)
await websocket.recv()

This at least does connect to the mopidy websocket server because if the server if offline I get a error message from Flask webserver. However, if its online and probably connected, how do I send and receive messages?

got that code from websocket documentation