User registration, password hashing with bcrypt, session management, and the Flask-Login decorators that protect views without repeating auth logic everywhere.
User registration, password hashing with bcrypt, session management, and the Flask-Login decorators that protect views without repeating auth logic everywhere.
pip install flask-wtf
app.config['SECRET_KEY'] = 'your-secret-key' # required for CSRFfrom flask_wtf import FlaskForm
from wtforms import StringField, TextAreaField, EmailField
from wtforms.validators import DataRequired, Email, Length
class ContactForm(FlaskForm):
name = StringField('Name', validators=[DataRequired(), Length(min=2, max=50)])
email = EmailField('Email', validators=[DataRequired(), Email()])
message = TextAreaField('Message', validators=[DataRequired(), Length(min=10)])from .forms import ContactForm
from flask import flash
@app.route('/contact', methods=['GET', 'POST'])
def contact():
form = ContactForm()
if form.validate_on_submit():
# form is valid and it was a POST
flash('Message sent!', 'success')
return redirect(url_for('index'))
return render_template('contact.html', form=form)form.hidden_tag() to your forms.form.validate_on_submit() returns True only on valid POST requests — the one method you need.flash('message', 'category') in the view, get_flashed_messages() in the template.The foundations from today carry directly into Day 4. In the next session the focus shifts to REST APIs and Flask-RESTful — building directly on everything covered here.
Before moving on, verify you can answer these without looking:
Live Bootcamp
Learn this in person — 2 days, 5 cities
Thu–Fri sessions in Denver, Los Angeles, New York, Chicago, and Dallas. $1,490 per seat. June–October 2026.
Reserve Your Seat →