Python flask redirect with error Python flask redirect with error flask flask

Python flask redirect with error


You'll need to place try/except dependent return statements to handle that. The issue is that no matter what happens in the try/except it will always go to the login page if it enters the if statement. You'll need to break up your return statements accordingly.

@app.route('/signup', methods=['GET','POST'])def signup():    error = None    if request.method == 'POST':        try:            ... my code ...            return redirect(url_for('login'))        except Exception, e:            error = "hey this is error"            ... i want to redirect to signup with error ...            return render_template('signup.html', error=error)    return render_template('signup.html', error=error)