Python Websocket Server Example
This script runs a websocket server in a local laptop.
Python Installation
- Install python 3: https://www.python.org/
- In a terminal, install:
pip install websockets- If on Mac, use a virtual environment:
- Open the terminal in the directory of the python server script
- In the terminal write
python3 -m venv venvorpython -m venv venv - In the terminal write
source venv/bin/activate. You should now see (venv) followed by your directory - In the terminal write
pip install websockets
- Run the python script with
python WebsocketServerExample.pyorpython3 WebsocketServerExample.py- Note! On Mac you will always need to run "source venv/bin/activate" every time you open a new terminal window before running the server python script
- You should now see "WebSocket server running on IP ( ** Your IP address ** ) port ( ** Your port ** )"
- Use this IP address in your configuration of Websocket Clients