WSocket
Simple WSGI HTTP + Websocket Server, Framework, Middleware And App.
Install / Use
/learn @ksenginew/WSocketREADME
About The Project
This is a simple library to add websocket support to WSGI.
- Server - Patched wsgiref server
- Middleware - Add websocket support to Flask, Django, Pyramid, Bottle, ...
- Handler - Websocket handler to wsgiref
- Framework - Basic websocket + WSGI web application framework
- App - Plug and play demo app.
Getting Started
This is an example of how you may give instructions on setting up your websocket connunication locally.
Installation
You can
- Installing from PyPI
- Download:down_arrow: and Include
Installing from PyPI
Install latest version or upgrade an already installed WSocket to the latest from PyPI.
pip install --upgrade wsocket
Download and Include
- Visit wsocket.py.
- Save file (
ctrl+sin browser). - Include in your package derectory.
my-app/
├─ hello_world.py
├─ wsocket.py
Usage
- Include following source on your test file(eg:-
hello_world.py).
from wsocket import WSocketApp, WebSocketError, logger, run
from time import sleep
logger.setLevel(10) # for debugging
def on_close(self, message, client):
print(repr(client) + " : " + message)
def on_connect(client):
print(repr(client) + " connected")
def on_message(message, client):
print(repr(clent) + " : " + repr(message))
try:
client.send("you said: " + message)
sleep(2)
client.send("you said: " + message)
except WebSocketError:
pass
app = WSocketApp()
app.onconnect += on_connect
app.onmessage += on_message
app.onclose += on_close
run(app)
- Visit client.html.
- Save file (
ctrl+sin browser). - Open it in browser(websocket supported).
- Experience the two way websocket communication. :smile::smile::smile:
Contributing
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
Code and documentation are available according to the MIT License (see LICENSE).
Contact
Report Bugs - https://github.com/Ksengine/WSocket/issues/new/
Related Skills
canvas
351.2kCanvas Skill Display HTML content on connected OpenClaw nodes (Mac app, iOS, Android). Overview The canvas tool lets you present web content on any connected node's canvas view. Great for: -
node-connect
351.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
110.6kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
110.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
