Hacker News new | ask | show | jobs
by bernardv 1913 days ago
This is great. Does it rely on web sockets?
3 comments

Looking at it from the web inspector, yes, it's entirely over websockets, sending json messages :

    {"event":"input_event","task_id":"main-140213579376912","data":{"event_name":"blur","name":"weight","value":"21"}}
    {"command": "output", "spec": {"type": "markdown", "content": "Your BMI: `1458.3`, Category: `Severely obese`", "sanitize": true, "scope": "#pywebio-scope-ROOT", "position": -1}, "task_id": "main-140213579376912"}
It seems to stream the HTML over the original HTTP socket– web browsers can render incomplete streams of HTML.
Both http and websocket protocol can be used to implement server-browser communication in PyWebIO. The websocket is default, and you can use `pywebio.platform.tornado_http.start_server()` or `pywebio.platform.path_deploy_http()` to use http polling to communicate.