{"id":17017599,"url":"https://github.com/datahappy1/flask_sse_example_project","last_synced_at":"2025-06-16T22:07:18.492Z","repository":{"id":50655848,"uuid":"219358847","full_name":"datahappy1/flask_sse_example_project","owner":"datahappy1","description":"Flask, Waitress and Javascript used for multiple Server-sent event streams to enable long running jobs web browser auto-refresh","archived":false,"fork":false,"pushed_at":"2023-05-06T20:55:54.000Z","size":124,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-22T18:48:37.398Z","etag":null,"topics":["auto-refresh","flask","html5","javascript","long-running-process","server-sent-events","waitress"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datahappy1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-11-03T20:09:20.000Z","updated_at":"2024-09-19T19:50:02.000Z","dependencies_parsed_at":"2025-04-22T18:40:54.536Z","dependency_job_id":null,"html_url":"https://github.com/datahappy1/flask_sse_example_project","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/datahappy1/flask_sse_example_project","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datahappy1%2Fflask_sse_example_project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datahappy1%2Fflask_sse_example_project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datahappy1%2Fflask_sse_example_project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datahappy1%2Fflask_sse_example_project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datahappy1","download_url":"https://codeload.github.com/datahappy1/flask_sse_example_project/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datahappy1%2Fflask_sse_example_project/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260249966,"owners_count":22980765,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auto-refresh","flask","html5","javascript","long-running-process","server-sent-events","waitress"],"created_at":"2024-10-14T06:37:03.056Z","updated_at":"2025-06-16T22:07:18.469Z","avatar_url":"https://github.com/datahappy1.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flask, SSE, JS example project\nFlask, Waitress and Javascript used for 1-N Server-sent event streams to enable long running jobs state auto-refresh visualized in a HTML table in the browser\n\n\u003e Server-Sent Events (SSE) is a server push technology enabling a client to receive automatic updates from a server via HTTP connection. The Server-Sent Events EventSource API is standardized as part of HTML5 by the W3C.\n\nCurrently this project is designed to run on Windows, but if you replace Waitress WSGI with Gunicorn for instance, it can\nrun also on *nix based OS\n\nThis project needs to be run in a browser fully supporting HTML5 \n\n## 10000 ft. overview Diagram\n![alt text][diagram]\n\n[diagram]: https://github.com/datahappy1/flask_sse_example_project/blob/master/flaskr/docs/diagram.png \"diagram\"\n\n## Screenshots from the web app\n![alt text][screens]\n\n[screens]: https://github.com/datahappy1/flask_sse_example_project/blob/master/flaskr/docs/screens.gif \"screens\"\n\n\n## How it works\n1) Flask backend before each app startup imports blueprints with the SSE streaming routes from the folder `/blueprints/`\n2) These routes publish the events into `http://127.0.0.1:80/streams/\u003cstream_name\u003e`\n3) Flask generates the HTML templates, template `stream.html` has JavaScript code attached, which uses\nJSON2HTML JS library to change the event stream from JSON to HTML table rows and injects these rows in the \ntable used for jobs statuses visualization\n4) You can create a new stream by importing and registering into `app.py` a new blueprint\n\n\n## How to get started\n1) Git clone this repository\n2) Create and activate yourself a Python virtual environment\n3) run `pip3 install -r requirements.txt`\n4) set your Windows Python working directory to `C:\\\u003c\u003c\u003cfolder where you cloned this repo to\u003e\u003e\u003e\\flaskr`\n5) run `python3 C:\\\u003c\u003c\u003cfolder where you cloned this repo to\u003e\u003e\u003e\\flaskr\\app.py`\n\n### Useful links:\n- https://stackoverflow.com/questions/30645664/how-to-stop-server-sent-events \n- https://medium.com/brillio-data-science/exposing-your-data-science-project-to-the-world-flask-with-a-waitress-8592f0356b27\n- https://stackoverflow.com/questions/12232304/how-to-implement-server-push-in-flask-framework\n- https://medium.com/code-zen/python-generator-and-html-server-sent-events-3cdf14140e56\n- https://json2html.com/examples/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatahappy1%2Fflask_sse_example_project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatahappy1%2Fflask_sse_example_project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatahappy1%2Fflask_sse_example_project/lists"}