We've spoken so much about this fancy form library - WTForms, let's see it in action and create a form using it in our Flask application.

Download the Starting Files

Download the starting files (see lesson resources) and unzip the folder. Open the unzipped folder in PyCharm. You might see a warning like the one in the screenshot below, click on "Install Requirement" to install Flask.

Challenge

Create the login route which renders the login.html file.

Run the app to make sure it works. This is what you should see when you run it:

SOLUTION


Install Flask-WTF Extension

The requirements.txt file is a file where you can specify all the dependencies (the installed packages that your project depends on) and their versions. This means that you can share your project without all the installed packages, making it a lot more lightweight. When someone downloads your project (like you have done here), the requirements.txt file tells their code editor which packages need to be installed. Read more on this here.


2. Use the Terminal to install Flask-WTF. Installation documentation: https://flask-wtf.readthedocs.io/en/1.0.x/install/

pip install Flask-WTF

*pip installs are always case sensitive!