Skip to Content
Building Web Applications with Flask
book

Building Web Applications with Flask

by Italo Maia
June 2015
Intermediate to advanced
160 pages
3h 22m
English
Packt Publishing
Content preview from Building Web Applications with Flask

WTForms and you

WTForms (https://github.com/wtforms/wtforms) is a standalone robust form handling library that allows you to generate HTML forms from form-like classes, implement fields and form validation, and include cross-source forgery protection (a nasty vulnerability that crackers may try to exploit in your Web applications). We certainly don't want that!

First, to install WTForms library, use the following:

pip install wtforms

Now let's write some forms. A WTForms form is a class that extends the Form class. As plain as that! Let's create a login form that could be used with our previous login example:

from wtforms import Form, StringField, PasswordField class LoginForm(Form): username = StringField(u'Username:') passwd = PasswordField(u'Password:') ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Building RESTful Python Web Services

Building RESTful Python Web Services

Gastón C. Hillar

Publisher Resources

ISBN: 9781784396152Supplemental Content