Python Forum

Full Version: Reload flask current page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi
I am developing a Flask app that communicates with a back end via pipes.
I need to reload the current page of the Flask app when an update is received from the back end, but cannot see how to do this.

Is there a way of forcing a refresh of the current page?
I suggest reload some page parts with ajax call to backed, this call to backed can be with some interval.

function fetchdata(){
 $.ajax({
  url: 'fetch_details.php',
  type: 'post',
  success: function(response){
   // Perform operation on the return value
   alert(response);
  }
 });
}

$(document).ready(function(){
 setTimeout(fetchdata,5000);
});
(Jan-08-2021, 08:19 AM)kashcode Wrote: [ -> ]I suggest reload some page parts with ajax call to backed, this call to backed can be with some interval.

function fetchdata(){
 $.ajax({
  url: 'fetch_details.php',
  type: 'post',
  success: function(response){
   // Perform operation on the return value
   alert(response);
  }
 });
}

$(document).ready(function(){
 setTimeout(fetchdata,5000);
});

Thanks for the response
However, I'm not sure what you are getting at.
I do not need to refresh at an interval but when I get pipe input from a separate program.
In the Flask app the user presses a button which results in a message being sent via a pipe to a separate program. When this other program receives the message it performs some processing and writes a response to the pipe and this is then received by the Flask app. When the Flask app receives the reply I want to reload a page in the Flask app.