I am inserting the data in database using Flask SQLAlchemy Everything is going fine when I insert data using "/" in action attribute code but when I use to redirect to action="users.html" page after posting the data I get the message "the method is not allowed for requested url in users page and data does not save too"
<form method="POST" action="/">
Name <input type="text" name="name">
<br>
Password <input type="text" name="email">
<br>
<input type="submit">
</form>
class Users(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80), unique=True, nullable=False)
email = db.Column(db.String(120), unique=True, nullable=False)
@app.route("/", methods = ['GET', 'POST'])
def contact():
if(request.method=='POST'):
'''Add entry to the database'''
name = request.form.get('name')
email = request.form.get('email')
entry = Users(name=name, email=email)
db.session.add(entry)
db.session.commit()
return render_template('index.html')
@app.route('/users')
def users():
return render_template('users.html')