Flask redirect(urlfor())为什么不起作用?

问题描述 投票:0回答:1
@app.route('/result',methods=['GET','POST'])

def result(res):

    return render_template('public/inherit.html',res=res)

@app.route('/',methods=["POST","GET"])

def index():

    if request.method == "POST":
        a = 12
        redirect(url_for('result',res=a))
    return render_template('public/index.html'

index.html

    <form method="post" action="{{ url_for('index') }}">
        <input type="submit" name="Login" value="Submit">
    </form>

inherit.html

<p>{{ res }}<p>
python flask flask-wtforms flask-login flask-admin
1个回答
0
投票

更改

@app.route('/result',methods=['GET','POST'])

收件人

@app.route('/result/<res:int>',methods=['GET','POST'])
© www.soinside.com 2019 - 2024. All rights reserved.