File size: 604 Bytes
b467181
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python

# WS client example

import asyncio
import websockets

async def hello():
    uri = "wss://palondomus-caesarmusic.hf.space/caesarmusicws"
    async with websockets.connect(uri) as websocket:
        

        await websocket.send({"artist":"a boogie wit da hoodie","album":"hoodie szn","album_or_song":"album"})
        while True:
            greeting = await websocket.recv()
            if "message" in greeting:
                print(greeting)
                if "finished"in greeting["message"]:
                    break


asyncio.get_event_loop().run_until_complete(hello())