Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

PY | websocket - server

#!/usr/bin/env python

import asyncio
import websockets

async def echo(websocket, path):
    async for message in websocket:
        await websocket.send(message)

asyncio.get_event_loop().run_until_complete(
    websockets.serve(echo, 'localhost', 8765))
asyncio.get_event_loop().run_forever()
Comment

PY | websocket - client

#!/usr/bin/env python

import asyncio
import websockets

async def hello(uri):
    async with websockets.connect(uri) as websocket:
        await websocket.send("Hello world!")
        await websocket.recv()

asyncio.get_event_loop().run_until_complete(
    hello('ws://localhost:8765'))
Comment

PREVIOUS NEXT
Code Example
Python :: how to convert tuple into list in python 
Python :: os chdir python 
Python :: merge two dictionaries 
Python :: Python "for in" loop to print the last item in the list 
Python :: kpss test python 
Python :: addition of matrix in python using numpy 
Python :: pyautogui locatecenteronscreen mac fix 
Python :: django templates 
Python :: check if list is empty python 
Python :: docker mount volume 
Python :: IndentationError: unexpected indent 
Python :: pandas.core.frame.DataFrame to pandas.core.series.Series 
Python :: how to type using selenium python 
Python :: for enumerate python 
Python :: python ffmpeg get video fps 
Python :: how to check encoding of csv 
Python :: pandas order dataframe by index of other dataframe 
Python :: driver find element with multiple classes python 
Python :: how to make python code faster 
Python :: square a number in python 
Python :: how to get size of list in python 
Python :: python requests-session for websites with login 
Python :: python enumerate for loop 
Python :: python logo png 
Python :: how to correlation with axis in pandas 
Python :: python to make video 
Python :: react-native-dropdown-picker 
Python :: code folding vim python 
Python :: flask sending post request 
Python :: random.uniform python 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =