【发布时间】:2018-11-15 12:59:17
【问题描述】:
所以我在烧瓶上运行了这个 python 页面。在我想要重定向之前它工作正常。
@app.route("/last_visit")
def check_last_watered():
templateData = template(text = water.get_last_watered())
return render_template('main.html', **templateData)
return redirect(url_for('new_page')) #with a delay here of 3 secs
该站点运行良好,但没有重定向,我不知道如何延迟整个过程。 想法...请:-)
【问题讨论】:
-
使用
sleep()可能会有所帮助。 -
你不能从一个函数返回两次,也不能告诉浏览器渲染一个页面然后重定向。返回使用 Javascript 重定向的页面或返回 HTTP 重定向。 (你应该明白
redirect方法实际上做了什么) -
好的,好吧......两秒钟后页面应该转发到另一个页面。