Updating progress bar with Flask
In display.html update your script tag:
<script>
var source = new EventSource("/display_progress");
source.onmessage = function (event) {
$('.progress-bar').css('width', event.data + '%').attr('aria-valuenow',event.data);
$('.progress-bar-label').text(event.data + '%');
if (event.data == 100) {
source.close()
}
}
</script>
How to create a progress bar using flask?
this is pretty simple: poll your api and update the progress bar width and valuenow until finished:
var interval = setInterval(update_progress, 1000);
function update_progress() {
$.get('/progress').done(function(n){
n = n / 5; // percent value
if (n == 100) {
clearInterval(interval);
callback(); // user defined
}
$('.progress-bar').animate({'width': n +'%'}).attr('aria-valuenow', n);
}).fail(function() {
clearInterval(interval);
displayerror(); // user defined
});
}
Related Topics
Pygame Window Not Responding After Few Seconds
How to Find Which Columns Contain Any Nan Value in Pandas Dataframe
Sqlalchemy Unique Across Multiple Columns
I Have Python on My Ubuntu System, But Gcc Can't Find Python.H
How Does My Input Not Equal the Answer
Tkinter Grid_Forget Is Clearing the Frame
Opencv Python: Cv2.Findcontours - Valueerror: Too Many Values to Unpack
Test Case Execution Order in Pytest
How to Improve My Paw Detection
Printing a List Separated with Commas, Without a Trailing Comma
Remove All Line Breaks from a Long String of Text
Python 2.X Gotchas and Landmines
Differencebetween Join and Merge in Pandas
Multiplying Across in a Numpy Array
Do You Use the "Global" Statement in Python
How to Flatten a List of Lists/Nested Lists