Make form validation a breeze

Photo by Alejandro Escamilla on Unsplash

Meta Information

Goals

  • Introduction on how to use Flask-WTForms to simplify form generation and validation
  • Use Flask-WTForms to build a functioning Flask application with only one registration page. The end product looks like:

Deployment

Photo by SpaceX on Unsplash

Meta Information About This Tutorial

Learning goals

  • Deployment

Note: This tutorial is part of the series Learn Flask in a scientific way.

Source code

  • The source code of this tutorial can be accessed on GitHub.
  • The demo can be accessed on this website.
  • The version that covers only this tutorial can be accessed on GitHub.

Plans

In this tutorial, we will deploy the web application we have been developing, and show it to the world:


Review system

Photo by Clint Adair on Unsplash

Meta Information About This Tutorial

Learning goals

  • Four basic functions of persistent storage — create, read, update, and delete (CRUD).

Note: This tutorial is part of the series Learn Flask in a scientific way.

Source code

  • The source code of this tutorial can be accessed on GitHub.
  • The demo can be accessed on this website.
  • The version that covers only this tutorial can be accessed on GitHub.

Plans

In this tutorial, we will develop and test the review system component of our web application.

Essentially, this component will allow anyone to view all the mean reviews added by all users, and allow users who registered an account with the application…


Authentication (continued)

Photo by Marvin Meyer on Unsplash

Meta Information About This Tutorial

Learning goals

  • Authentication

Note: This tutorial is part of the series Learn Flask in a scientific way.

Source code

  • The source code of this tutorial can be accessed on GitHub.
  • The demo can be accessed on this website.
  • The version that covers only this tutorial can be accessed here.

Plans

In this tutorial, we will continue our development and testing of the authentication component of our web application.

So far, we have a functioning registration page. Based on that, we will develop the login and logout functionalities, and test them thoroughly. Eventually, we want to achieve the following effect:


Restructuring testing

Photo by Yomex Owo on Unsplash

Meta Information About This Tutorial

Learning goals

  • Unit testing

Note: This tutorial is part of the series Learn Flask in a scientific way.

Source code

Install Your Application as a Package

As we move to use Application Factory and Blueprints, our testing code also needs some upgrade. To make our application that adopts Application Factory and Blueprints visible to testing code underneath a different folder, we need to install our application as a package first. There are three steps to achieve this.

First, we need to…


Use Application Factory and Blueprints

Photo by Sergey Zolkin on Unsplash

Meta Information About This Tutorial

Learning goals

  • Restructure a Flask project from a single script application to using an Application Factory and blueprints.

Note: This tutorial is part of the series Learn Flask in a scientific way.

Source code

Application Factory and Blueprints — What Are They and Why Do We Need Them?

Continuing from the last tutorial, we already have an application with tested registration functionality.

However, everything was coded in a single file, app.py. This approach is convenient but doesn’t scale well. …


User authentication - registration

Photo by Bernard Hermant on Unsplash

Meta Information About This Tutorial

Learning goals

  • User authentication — Registration

Note: This tutorial is part of the series Learn Flask in a scientific way.

Source code

Planning and Design

Our goal is to set up user registration in our application. To achieve this, we need a database table that stores user information. The table contains at least three columns:

  1. ID
  2. Username
  3. Password

Username has to be unique for each user. The route/view functions have to take this into consideration. …


Templates in Flask

Photo by freestocks.org on Unsplash

Meta Information About This Tutorial

Learning goals

  • Understand templates in Flask

Note: This tutorial is part of the series Learn Flask in a scientific way.

Source code

Planning and Design

Before we start building our application, we have to make a good plan. Our application at least needs seven pages to work:

  • Homepage: Present a list of mean reviews from different contributors.
  • About page: Introduce our service.
  • 404 page: When visitors request a page that doesn’t exist.
  • Register an account page: Allows people…

Since I started working as a faculty two years ago, I spent more time writing papers than code. For a research project that I started a few months ago, my students and I had to pick a framework that can support fast prototyping and can also be learned given a month or two. Eventually, we picked Flask, spent time learning it, and used it to develop our intended product. The project is still ongoing and moving on smoothly.

Same as others, when I had to learn Flask, I went over a set of different tutorials other developers put online, and…

Qiang Hao

Assistant Professor of Computer Science at Western Washington University; human; cat lover; qhao.info

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store