Start websocket

This commit is contained in:
sam
2024-02-13 16:26:54 +01:00
parent 251bb21d2a
commit c52da69a52

21
server/Websocket.py Normal file
View File

@@ -0,0 +1,21 @@
import websockets;
import asyncio;
async def handler(websocket):
while True:
#Save the incoming message in variable message.
message = await websocket.recv()
print(message)
async def main():
async with websockets.serve(handler, "145.92.8.114" , 8001):
await asyncio.Future() # run forever
if __name__ == "__main__":
asyncio.run(main())
#https://websockets.readthedocs.io/en/stable/reference/sync/server.html#websockets.sync.server.serve