Book Image

Flask Framework Cookbook

By : Shalabh Aggarwal
Book Image

Flask Framework Cookbook

By: Shalabh Aggarwal

Overview of this book

Table of Contents (19 chapters)
Flask Framework Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 5. Webforms with WTForms

Form handling is an integral part of any web application. There can be innumerable cases that make the presence of forms in any web app very important. Some cases can be where users need to log in or submit some data or cases where applications might require input from users. As important as the forms are, their validation holds equal importance, if not more. Presenting this information to users in an interactive fashion adds a lot of value to the application.

In this chapter, we will cover the following recipes:

  • SQLAlchemy model data as form representation

  • Validating fields on the server side

  • Creating a common forms set

  • Creating custom fields and validation

  • Creating a custom widget

  • Uploading files via forms

  • Cross-site Request Forgery protection