gpt4 book ai didi

javascript - Flask post 请求页面加载错误

转载 作者:行者123 更新时间:2023-12-03 01:47:56 25 4
gpt4 key购买 nike

每当我刷新页面时,就会在我的控制台中看到一个发布请求。这意味着它在我输入任何内容或单击任何按钮之前请求我的表单。我需要将其传递给 Jinja 并通过 js,但是,它将始终返回 0,因为变量用户名或密码中没有数据。

@app.route('/dosomething', methods = ['POST', 'GET'])
def dosomething():
if request.method == 'POST':
username = request.form['username']
password = request.form['password']
check = system.add_user(username,password)
if check == 1:
return redirect(url_for("login"))
return render_template('dosomething.html', check = check)
return render_template('dosomething.html')

最佳答案

您必须使用 307 http 代码进行重定向。

if check == 1:
return redirect(url_for('login'), code=307)

关于javascript - Flask post 请求页面加载错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50548962/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com