Flask

1 @app.route('/')
2 def index():
3     return redirect(url_for('login'))
4 
5 
6 @app.route('/login')
7 def login():
8     abort(401)

设置自定义的错误页面

1 @app.route('/login')
2 def login():
3     abort(404)
4 
5 
6 @app.errorhandler(404)
7 def page_not_found():
8     return 'this is 404 ', 404
原文地址:https://www.cnblogs.com/yugengde/p/8241515.html