Below you will find pages that utilize the taxonomy term “Websocket”
Guides
A WebSocket Client/Server Skeleton Using FastAPI
A production-ready WebSocket client/server app using FastAPI.
docker run --rm --name websocket-python-example -p 8080:8080 -it jecklgamis/websocket-python-example:main
Tech Stack
- FastAPI - async web framework with WebSocket support
- websockets - WebSocket client library
- Pydantic v2 - validation and settings management
- Docker - containerized deployment (Python 3.12-slim)
- Helm - Kubernetes deployment chart
- Ruff - linting and formatting
- pytest - testing with async support
Project Structure
├── app/
│ ├── __init__.py # Global logging init (INFO level)
│ ├── main.py # FastAPI application entry point
│ ├── config.py # Environment-specific settings (dev/test/prod)
│ └── routers/ # API route handlers
│ └── websocket.py # WebSocket /ws endpoint
├── tests/ # Test suite
├── deployment/
│ └── k8s/helm/ # Helm chart and deploy Makefile
├── websocket_client.py # WebSocket client
├── run-server.sh # Start the server
├── run-client.sh # Start the client
├── Dockerfile
├── Makefile
└── pyproject.toml
Getting Started
Prerequisites
# Clone the repository
git clone git@github.com:jecklgamis/websocket-python-example.git && cd websocket-python-example
# Install dependencies
make install-deps
# Start the dev server (uses .env.dev by default)
make run-dev
The server will be available at http://localhost:8080. This will reload on file changes.
