Main Content

Flask - first forms and responses with wtforms

Archive - Originally posted on "The Horse's Mouth" - 2015-10-12 20:29:02 - Graham Ellis

Using Flask, the wtforms module lets you set up your own forms - example [here] with the jinja template [here]. This example sets the for up, but does not handle reponses - indeed, a form submitted back will generate an error 405 and I have used this opportunity to use the app.errorhandler decorator to show custom error messages.

The following example at [here] shows a form that picks up the answers, and uses a template conditional to show either the answers or the form depensing on completion success - the template is [here].