flask-sock
WebSocket support for Flask
What it is and what it does
flask-sock is a Flask extension that adds WebSocket support to your application. Unlike some alternatives, it does not require a greenlet-based application server to function—it works out of the box with Flask's development server and can be deployed to production using standard WSGI servers like Gunicorn alongside Eventlet or Gevent for async handling. The extension integrates cleanly into Flask's routing model, letting you decorate handler functions to receive and send WebSocket messages.
The package depends on flask and simple-websocket for its core functionality. It's designed for developers who want bidirectional communication in Flask applications without the overhead of setting up a specialized server environment during development. For production, you pair it with an appropriate deployment strategy—Gunicorn with Eventlet or Gevent workers, or a standalone Eventlet/Gevent server.
Use it for:
- Build real-time chat or notification systems in Flask without switching to a specialized async framework.
- Add live data streaming or dashboard updates to existing Flask applications.
- Implement collaborative editing or multiplayer features where clients need instant server-to-client messaging.
- Create interactive debugging or monitoring tools that push status updates to connected clients.
- Develop browser-based games or interactive applications requiring low-latency bidirectional communication.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds WebSocket support to Flask applications without requiring greenlet-based servers, working with the Flask development server and production deployments via Gunicorn, Eventlet, or Gevent.
Yes, if you need WebSocket support in Flask and want to avoid greenlet-based servers during development. The package is actively maintained, has no known vulnerabilities, installs with minimal friction, and uses a permissive MIT license. It's well-suited for adding real-time features to existing Flask projects without major architectural changes.
Install
flask-sock on PyPI
pip
pip install flask-sockuv
uv add flask-sockpoetry
poetry add flask-sockInstalling flask-sock
Before you install
Low friction: pure Python wheel with only two runtime dependencies (flask and simple-websocket). Actively maintained with recent commits and no known vulnerabilities.
License in practice
MIT license permits commercial and private use with minimal restrictions; you may use, modify, and distribute the package freely provided you include the license notice.
Quickstart
pip install flask-sock
from flask import Flask
from flask_sock import Sock
app = Flask(__name__)
sock = Sock(app)
@sock.route('/echo')
def echo(ws):
while True:
data = ws.receive()
ws.send(data)
Requires Python 3.6 or later; for production use, deploy with Gunicorn, Eventlet, or Gevent rather than the Flask development server.
Verify before relying
- Whether the package's WebSocket implementation handles connection pooling or scales to high concurrency loads.
- Performance characteristics compared to other Flask WebSocket extensions in production deployments.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — flask, simple-websocket |
| Maintenance | actively maintained — 1,047 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,103,188/month — #3,294 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flask_sock-0.7.0-py3-none-any.whl
Tags
More Dynamic Content packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
soupsieveSoupsieve is a CSS selector library designed to…
permissive · top 100 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
FlaskFlask is a lightweight WSGI web application…
permissive · top 1,000 on PyPI
MakoMako compiles Python-embedded templates into…
permissive · top 1,000 on PyPI
Flask-SocketIOFlask-SocketIO adds real-time bidirectional…
permissive · top 5,000 on PyPI
bottle-websocketAdds WebSocket support to the Bottle web…
permissive · top 15,000 on PyPI
gevent-websocketProvides WebSocket support for gevent-based…
unclear · top 5,000 on PyPI
websocketProvides WebSocket protocol support for…
permissive · top 15,000 on PyPI
simple-websocketProvides a straightforward WebSocket server and…
permissive · top 1,000 on PyPI
grequestsGRequests wraps the requests library with…
permissive · top 15,000 on PyPI
ws4pyws4py implements the WebSocket protocol (RFC…
permissive · top 15,000 on PyPI
geventgevent provides lightweight concurrent…
permissive · top 1,000 on PyPI
lomondLomond is a WebSocket client library that…
permissive · top 5,000 on PyPI
zwave-js-server-pythonPython client library for communicating with…
permissive · top 15,000 on PyPI