Skip to content


Flask is a python micro-framework that simplifies the construction of web applications. This tutorial guides you through the development of a simple web application for managing students on courses. It is based on an excellent tutorial written by Mbithe Nzomo but updates the content for python 3.x, and covers some additional topics such as configuring and using the Anaconda python distribution and the PyCharm IDE. You can use the links at the bottom of the page to go to the original tutorial.

The tutorial is aimed primarily at students and makes use of tools that may require a paid licence if you are using them commercially. Please check the pricing information in each such case if you are not eligible for a free licence.


The application is used to manage the details of students taking modules as part of their programme of study. The terminology used is typical of UK universities:

Academic year: divides academic work up into annual sections. Typically starts in September

Programme: synonymous with course - indicates study activity that extends over several years

Module: individual topic studied as part of a programme. Typically lasts for one trimester

Cohort: the group of students taking a module at a particular time. Can also be used to mean a specific delivery of the module

We identify two user roles, Admin and Staff. Admin users managed the structural information in the systems, while staff users represent the tutors who teach on modules. The use cases associated with the two roles are illustrated in Figure 1. All diagrams can be expanded by clicking them.

Use cases Figure 1: Use cases

The entity-relationship diagram in Figure 2 describes the database structure that will be developed over the course of the tutorial.

ER diagram Figure 2: ER diagram

The ER diagram shows that a member of staff belongs to a subject group and may be the module leader for a particular module. The two different types of user are defined as roles and a member of staff may have permission to act in a particular role. A module runs in a particular academic year, and the group of students taking that delivery of the module form a cohort.


Model-View-Controller (MVC) is a common design pattern for web applications. It divides code up according to its purpose. A model is a piece of code that corresponds to an object in a database. Its job it to provide the link between instantiated objects in the application and their persistent storage. The purpose of a view is to present data to the user and to give them a way of interacting with it. Essentially, a view is part of the user interface and is therefore where all the design and presentation code is implemented. A controller element implements the business logic - i.e. the specific processing that the application needs to perform.

MVC Figure 3: MVC pattern

The separation if the three types of component is implemented purely by maintaining a set of coding and structuring conventions. Flask implements the MVC pattern, but its terminology is is slightly different as shown in the table below.

MVC term Flask term
Model Model
View Template
Controller View


The tutorial is divided into two main parts. The first part is for an individual developer working alone. It covers

  • Basic setup of the working environment
  • Main concepts required for the Flask application

The second part assumes that a team of developers will be working together. It covers

  • Configuring GitHub integrations in PyCharm
  • Code sharing
  • Branching
  • Merging

Further reading

 Flask CRUD tutorial (python 2.7) part 1

 Flask CRUD tutorial (python 2.7) part 2

 Flask CRUD tutorial (python 2.7) part 3