Overview

In this course, we’ll use a Python module called Flask to build our websites. Today’s prep gets you started understanding what Flask is and you should make sure that you have Flask installed (which you hopefully did through the venv guide at the start of the term).

Basic Learning Objectives

Before class, you should be able to:

  • Explain what Flask is
  • Explain what a web framework is
  • Describe the tasks that a web framework like Flask carries out
  • Be sure you have Flask installed on your machine

Advanced Learning Objectives

After class, you should be able to:

  • Use Flask to create a basic website
  • Use route parameters to dynamically change your website

Readings

To achieve the basic learning objectives, you should read the following sections of the Flask Tutorial on pythonbasics.org and try out the Hello World app:

  1. What is Flask
  2. Flask Tutorial - Hello World
  3. Flask Tutorial - Routes (ignore the ‘flask route post’ section, we’ll get to that later)

Checks

Verify that you’ve successfully installed Flask on your machine by:

  1. Activating your virtual environment
  2. Making a new file server.py and pasting in the boilerplate from the reading
  3. Run with python server.py and verify that you can see the “Hello World!” webpage
  4. If you can’t, go back to the virtual environment guide and follow all the install instructions and try again.

Submit answers to the following through Moodle:

  1. List one advantage of using Flask as opposed to another web framework.
  2. What is a route, and how is it used in Flask?
  3. What is one route parameter that you could use in your team project that would recreate your command line functionality in the browser?