如何在Flask中使用url参数?

时间:2019-10-18 19:09:53

标签: python flask

我正在尝试在render_template中的Flask中使用URL参数。当操作发生时,不会发送该参数。这是为了让create_account显示错误。

@app.route("/new_account", methods=['POST', 'GET'])
def new_account():
    return render_template("new_account.html")

@app.route("/create_account", methods=['POST', 'GET'])
def create_account():
    user = request.form['username']
    pw = request.form['password']
    email = request.form['email']
    check_user = connectDB.conUser(user=user)
    check = ''
    if email[-14:] != '@companyname.com':
        check += '1'
    if len(pw) < 8:
        check += '2'
    if check_user != []:
        check = '3'
    if check != '':
        print(check)
        return render_template("new_account.html", error=check)
    else:
        return home()

我希望看到类似127.0.0.1/new_account.html?error=12的URL。

0 个答案:

没有答案