Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aldanor/socketio-flask-debug
A Werkzeug-based debugger for gevent-socketio
https://github.com/aldanor/socketio-flask-debug
Last synced: 1 day ago
JSON representation
A Werkzeug-based debugger for gevent-socketio
- Host: GitHub
- URL: https://github.com/aldanor/socketio-flask-debug
- Owner: aldanor
- License: mit
- Created: 2013-09-28T16:52:06.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-06-11T20:08:59.000Z (over 10 years ago)
- Last Synced: 2024-05-02T01:37:45.608Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 168 KB
- Stars: 15
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
SocketIO-Flask-Debug
====================Holy cow, I have finally made the Werkzeug debugger work with gevent-socketio, see below for usage.
```python
# Server-side usagefrom socketio.server import SocketIOServer
from socketio.namespace import BaseNamespace
from debugger import SocketIODebuggerclass MyNamespace(BaseNamespace):
def on_my_message(self, data):
do_something()app.debug=True
app = SocketIODebugger(app, evalex=True, namespace=MyNamespace)SocketIOServer((host, port), app, resource='socket.io', policy_server=False).serve_forever()
```
```javascript
// Client-side usagesocket.on("exception", function () {
window.location.reload(true);
});
```
To test it, run `python app.py`, then browse to http://127.0.0.1:8080 and click on the buttons.How it works:
- extract the values from the generator returned by `werkzeug.debug.DebuggedApplication` whenever a
socket.io request is spotted, this enables to establish the socket connection properly;
- if a namespace is specified, wrap the namespace handlers in debugger's try/catch blocks;
- if an exception is caught within the namespace, save the full original traceback and emit an
"exception" socket message;
- inject exception reraising into `app.before_request()` which allows forwarding any incoming requests
to the debugger if an exception was caught within the namespace.Python dependencies: `flask`, `werkzeug`, `gevent`, `gevent-socketio`.