我在Flask上运行Web服务器,我希望在脚本createHTML.py完成后呈现html(index.html)
@app.route('/scan')
def cakes():
os.system('python3 createHTML.py')
return render_template('index.html')
由于此脚本耗时太长,我收到的错误是该网站没有发送任何信息。
我怎么能阻止这个?有没有办法让网站等到脚本完成才能显示页面?
这是按钮上运行的html:
<div style="text-align:center;">
<button href="scan" id="realScanButton" type="button">Scan Network</button>
</div>
这是重定向到python函数的脚本:
<script>
$( document ).ready(function() {
$("#realScanButton").click(function() {
clickEnBotonScan();
});
});
function clickEnBotonScan(){
$("#realScanButton").html('Scanning...');
$("#realScanButton").attr('disabled','disabled');
window.location.href = 'http://localhost:5000/scan';
return true;
}