我正在尝试将 404 重定向到外部 URL,如下所示:
@app.route('404')
def http_error_handler(error):
return flask.redirect("http://www.exemple.com/404"), 404
但它不起作用。我不断得到:
未找到
在服务器上找不到请求的 URL。如果您手动输入 URL,请检查拼写并重试。
你应该尝试这样的事情:
from flask import render_template
@app.errorhandler(404)
def page_not_found(e):
return render_template('404.html'), 404
Source http://flask.pocoo.org/docs/1.0/patterns/errorpages/ http://flask.pocoo.org/docs/1.0/patterns/errorpages/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)