I'm new to python and I am getting the error listed above
@app.route('/AddNewInfo', methods = ['GET', 'POST'])
def AddNewInfo():
if request.method == 'POST':
name = request.form['name']
email = request.form['email']
submit = request.form['submit']
if submit:
with open("info.txt", "w") as text_file:
text_file.write((name, email))
return render_template('show_info.html',name=name, email=email)
else:
return render_template('AddNewInfo.html')
HTML:
<html>
<head>
<title>Add new information</title>
</head>
<body>
<h1>Enter New Info</h1>
<form action="" method="post">
Name: <input type="text" name="name"><br />
Email: <input type="text" name="email"><br />
<input type="submit" value="Submit">
</form>
</body>
</html>
It is something to do with if request.method == 'POST' method as it works if it is only returning AddNewInfo
FIXED Had a post request instead of get in my index.html