I'm trying to manipulate the following code to issue a 307 redirect, instead of the default 302. Code:
@app.route('/', methods=('GET', 'POST'))
def home():
if request.method == 'POST':
username = request.form.get('username')
user = User.query.filter_by(username=username).first()
if not user:
user = User(username=username)
db.session.add(user)
db.session.commit()
session['id'] = user.id
return redirect('/',code = 307)
user = current_user()
return render_template('home.html', user=user)
The functionality of the above code is after a user enters the username, redirect to the home page.
Although it's issued properly (by inspecting the according message in terminal), I keep getting a "This page isn't redirecting properly" from the browser. The same code works perfectly for the simple redirect
return redirect('/')
What am I missing ?