如何重定向到外部404页面的python烧瓶 [英] how to redirect to a external 404 page python flask
本文介绍了如何重定向到外部404页面的python烧瓶的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何实现这一点我是新来的python和烧瓶,我试图将我的404重定向到一个外部url像这样:
How can I achieve this I'm new to python and flask, I am trying to redirect my 404 to a external url like this:
@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
源 http://flask.pocoo.org/docs/0.10/patterns/errorpages/
这篇关于如何重定向到外部404页面的python烧瓶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文