Lab: getting started with Flask

Nothing to hand in

Flask: a web framework

To create the back end of our web application, we're going to do what most web developers do—we're going to use a web framework. That is, we're going to use a library that is designed to simplify many of the tedious or difficult parts of web application implementation.

Because almost all of you have studied python before, we are going to use a web framework written in python. Furthermore, since your web application is going to be quite simple, we will want to use a web framework that requires minimal code to get started. As of now (spring 2025), the most popular light-weight python-based web frameworks are FastAPI and Flask. We will use Flask.

You can read all about Flask online, and we'll talk about many of its features as we go along, but for now, we just want to get going as quickly as possible.

Installing Flask on your own computer

Step 0: for WSL users only

Are you using WSL? Then you probably need to update your python3 installation before proceeding to the next section. This should do it.

Step 1: create a python virtual environment

The Flask installation documentation encourages you to use a thing called a virtual environment for your development work. We'll go along with this plan, even though it adds an additional weird new thing for you to think about.

Install Flask into your virtual environment

Launch the first flask sample

In my repo, there's a folder called flask containing a couple sample programs. Today, we're going to work with the one called flask_sample.py.