def contact(): form = ContactForm() if request.method == 'POST': if form.validate() == False: flash('All fields are required.') return render_template('index.html', form=form) else: if insert(request.form['name'], request.form['color'], request.form['pet']) == True: form.resultMessage = "Inserted Successfully" form.result = True return render_template('index.html', form=form) else: form.resultMessage = "Insertion Failed, please enter a unique name" form.result = False return render_template('index.html', form=form) elif request.method == 'GET': return render_template('index.html', form=form)