websockets
websockets copied to clipboard
path not subscriptable
Hi. The path variable in the handler function of a ws-server is not subscriptable, you can't convert it to a string which makes using the path variable a little bit difficult. I suggest the possibility to convert the path to str.
Could you say what version of Python you're using?
I'm using python 3.8.2
I cannot reproduce this issue with the information you provided. print(type(path)) at the beginning of a handler prints <class 'str'>. This is a string.
Try it for yourself with this diff:
diff --git a/example/server.py b/example/server.py
index c8ab699..444f6c9 100755
--- a/example/server.py
+++ b/example/server.py
@@ -6,6 +6,7 @@ import asyncio
import websockets
async def hello(websocket, path):
+ print(type(path))
name = await websocket.recv()
print(f"< {name}")