2

I want to change templates when a button is clicked.

Here is my python code:

@app.route("/", methods = ['POST', 'GET'])
def my_forum_post():
    
    if request.method == 'POST':
        if request.form['myBtn'] == 'Sign in':
            return render_template('new_profile.html')

And here is my HTML code:

<form method = 'POST'>
      <input type="button" name="myBtn"  value="Sign in">
</form>

And the template which i want to swich to is called: new_profile.html

1 Answers1

2

The problem is with this line of your code:

text = request.form('input')

Change it to this:

text = request.form['input']

or this

text = request.form.get('input')
IoaTzimas
  • 10,538
  • 2
  • 13
  • 30