from flask import request,render_template,abort @app.route('/login',methods = ['GET','POST']) def login(): if request.method = 'POST': if '_xsrf' not in request.form: abort(403) return render_template('login.html')
from flask import render_template #错误状态码404的处理
@app.errorhandler(404) def page_not_found(error): return render_template('page_not_found.html'), 404
# 处理特定的异常项
@app.errorhandler(ZeroDivisionError) def zero_division_error(e): return '除数不能为0'