title: What is the best way to update all clients when Flask database changes without polling?
body: <p>Currently I have a Flask server that runs a small web frontend as well as a command line interface to that same server.  The basic idea looks like this:</p>
  
  <pre><code>&lt;Top section: allows file upload&gt;
     * list of files from database
  
  &lt;Second section: allows file manipulation/ upload&gt;
    * list of files  from database
  
  &lt;Third section: Not files, but still allows for database changes&gt;
    * list of things made from database  
  </code></pre>
  
  <p>Now this works well from the front end, but currently if the CLI or another client makes a change to the database, it doesn't update other clients. I have it somewhat working with JS polling and rewriting the list of files every 10s, but that seems both inefficient and also would look very messy if I had to do it for every section.  I saw websockets mentioned in various forums, but I've never used them and am unsure if it would be a pain to add.  I'm not trying to rewrite the whole thing for a single feature.</p>
  
  <p><strong>Final takeaway:</strong> How to update all clients better than polling/ how to do polling efficiently?</p>