【发布时间】:2018-02-01 00:45:54
【问题描述】:
在menu.html 中,单击给定链接会以这种方式呈现所选页面pasta.html:
<ul>
<li><a href="{{ url_for('pasta') }}";>Pasta</a>
<form action="{{ url_for('handle_menu') }}" method="post">
<input type="radio" name="additive" value="Cheese"> <label style="font-size: 11px;">Cheese</label>
</form>
</li>
但是假设@app.route('/pasta') 必须在“完成”之前“烹饪”一些“配料”:
@app.route('/pasta')
def pasta():
# (perform some long task here)
return render_template('pasta.html')
就此而言,我想在页面加载时显示/cooking 视图,如下所示:
@app.route('/cooking')
def cooking():
return render_template('cooking.html')
如果我没记错的话,使用 Flask 和 jinja2 模板,您可以返回 (200) 或重定向 (301) 页面,对于像 loading.html 这样的任何中间页面,您需要 @ 987654333@.
那么,我如何在此处使用javascript 以显示cooking.html 页面同时 等待/pasta 任务完成,并且一旦任务完成,终于退货了?
【问题讨论】:
标签: javascript jquery flask jinja2