← Back to Python Study Repository
The ws folder contains scripts and configurations for learning and implementing WebSocket communication. Below is an overview of the contents and their purposes:
README.md: Provides an overview and resources for learning WebSocket communication.main.js: Initializes the user interface for a Connect Four game.run_interactive.txt: Instructions for connecting to a WebSocket server interactively.app_ws.py: The WebSocket server script handles and prints incoming messages.index_ws.html: HTML file for the Connect Four game, integrating themain.jsscript.server_ws.py: WebSocket server script that echoes received messages.client_ws.py: WebSocket client script that sends and receives messages.
To run the WebSocket server, use the following command:
python app_ws.pyThis will start a WebSocket server on port 8001.
To run the WebSocket client, use the following command:
python client_ws.pyThis will connect to the WebSocket server on ws://localhost:8765 and send a "Hello world!" message.
To run the Connect Four game, open the index_ws.html file in a web browser. The game board will be initialized, and you can interact with it.
The scripts in the ws folder provide a starting point for learning and implementing WebSocket communication. Follow the instructions for running the server and client scripts, and explore the Connect Four game for a practical example of WebSocket usage.
For more information on WebSockets, refer to the following resources: