Created
September 2, 2023 04:39
-
-
Save ApexExpress/ff0cedba6e9e6cf0616711f9584cf4de to your computer and use it in GitHub Desktop.
asyncio websockets gist
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 echo(websocket): | |
async for message in websocket: | |
await websocket.send(message) | |
async def main(): | |
async with websockets.serve(echo, "localhost", 8765): | |
await asyncio.Future() # run forever | |
asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This one is supposed to setup a service handler for websockets and return a resolve response message.