为了避免刷新整个页面,你需要使用AJAX。看起来这很容易在flask中实现。
由于你希望它定期发生,因此需要从javascript中的计时器函数调用AJAX函数。
这意味着你只需将flask页面中的javascript放入计时器调用中即可。
这大概是javascript的样子:
setInterval( //Periodically function() { $.getJSON( //Get some values from the server $script_ROOT + '/get_values', // At this URL {}, // With no extra parameters function(data) // And when you get a response { $("#result").text(data.result); // Write the results into the// #result element }); }, 500); // And do it every 500ms


