Skip to Main Content
Learning Flask Framework
book

Learning Flask Framework

by Matt Copperwaite, Charles Leifer
November 2015
Beginner content levelBeginner
250 pages
5h 16m
English
Packt Publishing
Content preview from Learning Flask Framework

Creating comments using AJAX

In order to allow users to post comments, we first need a way to capture their input, which we will do by creating a Form class with wtforms. This form should allow users to enter their name, email address, an optional URL, and their comment.

In the forms module in the entries blueprint, add the following form definition:

class CommentForm(wtforms.Form): name = wtforms.StringField('Name', validators=[validators.DataRequired()]) email = wtforms.StringField('Email', validators=[ validators.DataRequired(), validators.Email()]) url = wtforms.StringField('URL', validators=[ validators.Optional(), validators.URL()]) body = wtforms.TextAreaField('Comment', validators=[ validators.DataRequired(), validators.Length(min=10, max=3000)]) ...
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

Flask Framework Cookbook - Second Edition

Flask Framework Cookbook - Second Edition

Shalabh Aggarwal
Flask Framework Cookbook

Flask Framework Cookbook

Shalabh Aggarwal

Publisher Resources

ISBN: 9781783983360Supplemental Content