Giter VIP home page Giter VIP logo

flask_sse_example_project's Introduction

Flask, SSE, JS example project

Flask, 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

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.

Currently this project is designed to run on Windows, but if you replace Waitress WSGI with Gunicorn for instance, it can run also on *nix based OS

This project needs to be run in a browser fully supporting HTML5

10000 ft. overview Diagram

alt text

Screenshots from the web app

alt text

How it works

  1. Flask backend before each app startup imports blueprints with the SSE streaming routes from the folder /blueprints/
  2. These routes publish the events into http://127.0.0.1:80/streams/<stream_name>
  3. Flask generates the HTML templates, template stream.html has JavaScript code attached, which uses JSON2HTML JS library to change the event stream from JSON to HTML table rows and injects these rows in the table used for jobs statuses visualization
  4. You can create a new stream by importing and registering into app.py a new blueprint

How to get started

  1. Git clone this repository
  2. Create and activate yourself a Python virtual environment
  3. run pip3 install -r requirements.txt
  4. set your Windows Python working directory to C:\<<<folder where you cloned this repo to>>>\flaskr
  5. run python3 C:\<<<folder where you cloned this repo to>>>\flaskr\app.py

Useful links:

flask_sse_example_project's People

Contributors

datahappy1 avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.