异常处理:
abort(404)-捕获HTTP抛出的统一状态码
@app.errorhandler-捕获全局异常错误码,捕获异常错误
@app.route("/demo4")
def demo4():
abort(404)
return "demo4"
#
@app.errorhandler(404)
def page_not_found(error):
return "找不到你要的页面" @app.route("/demo5")
def demo5():
a = 0
b = 1/a
return "demo5" @app.errorhandler(ZeroDivisionError)
def zero_division_error(error):
return "除数不能为0"