将此添加到你的index.html或js文件中(我假设你在这里有jQuery,你当然可以使用标准javascript。):
<script type="text/javascript">// <![CDATA[
function loading(){
$("#loading").show();
$("#content").hide();
}
// ]]></script>
div#loading {
width: 35px;
height: 35px;
display: none;
background: url(/static/loadingimage.gif) no-repeat;
cursor: wait;
}
<input type="submit" name="anything_submit" value="Submit" onclick="loading();">
<body>
<div id="loading"></div>
<div id="content">
<h3>Type anything:</h3>
<p>
<form action="." method="POST">
<input type="text" name="anything" placeholder="Type anything here">
<input type="submit" name="anything_submit" value="Submit" onclick="loading();">
</form>
</p>
</div>
</body>
现在,当你单击“提交”时,js函数应隐藏你的内容并显示加载的GIF。这将一直显示,直到处理完你的数据并且flask加载新页面为止。