Simple WSGI HTTP + Websocket Server, Framework, Middleware And App.
Simple WSGI HTTP + Websocket Server, Framework, Middleware And App.
Explore the docs »
PyPI
·
Report Bug
·
Request Feature
This is a simple library to add websocket support to WSGI.
This is an example of how you may give instructions on setting up your websocket connunication locally.
You can
Install latest version or upgrade an already installed WSocket to the latest from PyPI.
pip install --upgrade wsocket
ctrl+s
in browser). my-app/
├─ hello_world.py
├─ wsocket.py
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)
ctrl+s
in browser).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.
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)Code and documentation are available according to the MIT License (see LICENSE).
Report Bugs - https://github.com/Ksengine/WSocket/issues/new/