Created
May 4, 2017 19:12
-
-
Save terrillo/04b7c546ffaac35a22608485396cc539 to your computer and use it in GitHub Desktop.
Simple Python WebSocket Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import asyncio | |
import websockets | |
async def hello(websocket, path): | |
name = await websocket.recv() | |
print(name) | |
await websocket.send(name) | |
start_server = websockets.serve(hello, 'localhost', 8765) | |
asyncio.get_event_loop().run_until_complete(start_server) | |
asyncio.get_event_loop().run_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment