I am trying to make a web-app using flask, and I am having a problem redirecting to another page/route that I have in my app.py file. I also set up a HTML template for the other (login) page.
Here is my code in the main app.py:
@app.route('/', methods=['GET', 'POST'])
if request.method == 'GET':
pass
if request.method == 'POST':
pass
return render_template('index.html', passable=passable)
@app.route('/login', methods=['GET', 'POST'])
def login():
if request.method == 'POST':
name = request.form.get('username')
post = request.form.get('password')
# still need to complete
return render_template('login.html')
I have imported all the relevant modules (I think).
In my Index.html file, I have a button, which I would like it to redirect to my login.html page. Currently I am doing something like this:
<button type="submit" onclick='{{Flask.redirect(url_for(login))}}' value="editor">
Whenever I launch the page (locally) i get this error. jinja2.exceptions.UndefinedError jinja2.exceptions.UndefinedError: 'Flask' is undefined
How do I make my button redirect to the "login" flask route?