from flask import Flask, abort, make_response, request, render_templateapp = Flask(__name__)# 重定向到百度
@app.route('/index', methods=["GET", "POST"])
def index():if request.method == "GET":return render_template("index.html")if request.method == "POST":name = request.form.get('name')password = request.form.get('password')if name == 'zhangsan' and password == '123':return '登录成功'else:abort(404)@app.errorhandler(404)
def handle_404_error(err):return "出现了404错误 错误信息是%s" % errif __name__ == '__main__':app.run(debug=True)