Building Data-Driven Web Apps with Flask and SQLAlchemy Course

Course Summary

One of the areas Python really shines is in building clean and powerful web applications. Once you know the language basics, this course will teach you everything you need to build data-driven, modern web applications in Python with the Flask web framework.

What students are saying

Working my way through the [...] bundle. GREAT tutorial/training! Well thought out and presented. Highly recommended.
-- Maarburg

Source code and course GitHub repository

github.com/talkpython/data-driven-web-apps-with-flask

Flask or Pyramid Web Framework?

This course is available in multiple web frameworks. Of course, this page is for the Flask version. It's also available from us in the Pyramid web framework.

What's this course about and how is it different?

Full stack web development is exactly what you need to build true data-driven web applications in Python. Yet these courses can be confusing and overwhelming due to the many technologies involved (Python, SQL, CSS, etc).

We have taken great care to build a course that is just real enough to give you what you need without anything extra. We build a replica of a popular web application, Python's own packaging index over at pypi.org.

While building our replica PyPI, you will learn:

  • Learn about the different major Python web frameworks
  • Create a Flask-based website from scratch using the CLI and PyCharm
  • Work with dynamic HTML templates
  • Map URLs to view methods using routing
  • Make advanced use of routing to build a full custom CMS in 8 minutes
  • Take advantage of bootstrap to build well designed sites
  • Map data to and from Python using classes with SQLAlchemy
  • Learn how Alembic can help our database evolve as our models change
  • Accept user input with HTML forms
  • Add client and server-side validation
  • Overcome the special challenges of testing web apps (databases, frameworks, etc)
  • Deploy our web application to a fresh Linux machine (virtual, cloud-based)
  • Leverage our design patterns to convert our app to another data model (MongoDB edition)

  • View the full course outline.

Who is this course for?

This course is for anyone who wants to create Python-based web applications using the Flask web framework. In fact, you'll learn a lot of web skills that will translate across frameworks as well.

We do assume that you have basic Python language skills and can read HTML and CSS. But most advanced uses of the language or CSS are explained in the course.

Follow along with your own version

Students get the most out of our courses when they work on projects closely related to the materials they are learning or even follow along by watching the videos and then recreating that code themselves chapter by chapter.

We have organized the source code included with the course to make following along starting from any chapter a breeze. In the screenshot below, you'll see two directories:

ch09_sqlalchemy/final
ch09_sqlalchemy/start

The start version is exactly what we started with on the videos for this chapter (chapter 9). If you want to follow along with chapter 9, just copy that somewhere and get started. Similarly, the final version is our final result exactly as it was on video. You can even diff the two directories to see the changes we made or against your work to see how we compare.

Here is the starter and final code from the SQLAlchemy database chapter.

Hands on exercises

Concepts backed by concise visuals

While exploring a topic interactively with demos and live code is very engaging, it can lose the forest for the trees. That's why when we hit a new topic, we stop and discuss it with concise and clear visuals.

Here's an example of concepts reviewing the basic idea of routing URLs to view methods and how Flask selects from the various URL routes given a single URL.

Example: Concepts backed by concise visuals

Follow along with subtitles and transcripts

Each course comes with subtitles and full transcripts. The transcripts are available as a separate searchable page for each lecture. They also are available in course-wide search results to help you find just the right lecture.

Each course has subtitles available in the video player.

Who am I? Why should you take my course?

Who is Michael Kennedy?

My name is Michael, nice to meet you. ;) There are a couple of reasons I'm especially qualified to teach you Python.

 1. I'm the host of the #1 podcast on Python called Talk Python To Me. Over there, I've interviewed many of the leaders and creators in the Python community. I bring that perspective to all the courses I create.

 2. I've been a professional software trainer for over 10 years. I have taught literally thousands of professional developers in hundreds of courses throughout the world.

 3. Students have loved my courses. Here are just a few quotes from past students of mine.

"Michael is super knowledgeable, loves his craft, and he conveys it all well. I would highly recommend his training class anytime." - Robert F.
"Michael is simply an outstanding instructor." - Kevin R.
"Michael was an encyclopedia for the deep inner workings of Python. Very impressive." - Neal L.

Free office hours keep you from getting stuck

One of the challenges of self-paced online learning is getting stuck. It can be hard to get the help you need to get unstuck.

That's why at Talk Python Training, we offer live, online office hours. You drop in and join a group of fellow students to chat about your course progress and see solutions via screen sharing.

Just visit your account page to see the upcoming office hour schedule.

Is this course based on Python 3 or Python 2?

This course is based upon Python 3. Python 2 is officially unsupported as of January 1st, 2020 and we believe that it would be ill-advised to teach or learn Python 2. This course is, and has always been, built around Python 3.

The time to act is now

This data-driven web apps with Python and Flask course is just what you need to build that fast, custom web application that can help you create your next great idea or just solve a business problem by deploying it behind your firewall.

Course Outline: Chapters and Lectures

Welcome to the course
25:57
Introducing the course
0:44
The incredible power of web
1:35
What is fullstack development?
3:16
Student expectations and pre-reqs
1:34
The technologies we will learn
2:27
What can you build with Python?
5:16
Course topics
6:04
Meet your instructor
0:51
What app will we build for this course?
2:05
Video player: A quick feature tour
2:05
Setup
6:10
Do you have Python 3? How do you get it?
2:40
Our code editor
0:58
PyCharm Pro for Free
0:30
Git the source code
0:36
Following along
1:26
Introducing the Flask framework
15:41
What are microframeworks?
2:38
Building blocks of Flask
3:31
Building block: Views
3:00
Building block: Routes and URLs
1:16
Building block: Models
1:49
Building block: Dynamic HTML Templates
2:28
Get the back story
0:59
Your first Flask site
20:14
Introduction to creating a Flask website
2:57
Demo: CLI starter site
5:55
Concepts: CLI starter site
3:00
Demo: Creating the starter project PyCharm
3:47
Concept: Creating the starter project PyCharm
1:25
Project structure
3:10
Jinja2 templates
44:11
Template chapter introduction
1:24
Jinja2 template example
2:30
Create the PyPI site
3:42
Our first jinja template
8:10
Concept: Jinja2 templates
1:42
Layout: Motivation
3:20
Jinja2 autocomplete in PyCharm
1:12
Adding a simple nav element
5:20
Creating a common layout page
5:08
Better organization for your template files
2:02
Concepts: Common layout
2:28
Project structure with shared layout
1:34
Demo: @response a better render_template
3:37
Concept: @response a better render_template
2:02
Routing and URLs
33:08
Routing visualized
3:52
Demo: Routing, loading the project
1:23
Refactoring view methods with Flask blueprints
9:12
Concept: Refactoring view methods with Flask blueprints
1:21
Adding a constrained route
3:42
The account management routes
2:59
Concept: Create route from url
1:28
How to build a CMS in 8 minutes
7:54
Concept: Routing to add a custom CMS
1:17
Bootstrap and frontend CSS frameworks
38:04
What we'll cover
0:53
CSS Front-end framework survey
2:02
Introduction to using Bootstrap
4:50
Running in a real web server
1:00
Intro to grid layout
2:53
Responsive browser tools
1:12
Grid layout in action
1:35
Adding to the grid
3:25
Concept: Grid layout
1:43
Buttons and forms
1:15
Buttons and forms in action
4:47
Style the login form
3:31
Concept: Buttons and forms
1:30
Why Bootstrap themes are awesome
1:43
Bootstrap theme tour
5:45
Adding our design
28:42
Our site design
3:14
Home page HTML
5:12
The making of the hero
5:22
Stats slice
3:20
New releases
3:48
Adding the navigation
3:49
Final footer
3:57
Modeling data with SQLAlchemy classes
54:50
Introducing SQLAlchemy
4:07
Who uses SQLAlchemy?
1:35
Architecture
2:14
The database model
3:10
Modeling packages
8:31
SQLAlchemy model base class
1:51
Connecting to our 'database'
6:01
Creating tables
6:26
Indexes
5:00
The rest of the tables
4:24
Relationships
7:16
Concepts: Modeling
4:15
Using SQLAlchemy
52:56
Creating the basic insert script
2:18
Connecting to the database (again)
1:36
Setting package values
1:33
Saving the package to the db
3:36
Running the inserts
2:34
Adding type hints to the session factory
1:20
Inserting real PyPI data
5:09
Concept: Unit of work
2:22
Querying data: Home page
5:55
Querying data: Latest releases
9:03
Working with package details
9:18
Concept: Querying data
4:03
Concept: Ordering data
0:44
Concept: Database updates
0:49
Concept: Relationships
1:59
Concept: Inserting data
0:37
Database migrations with Alembic
27:46
Introducing database migrations
3:47
Getting started with Alembic
2:32
Our first change
9:16
More database changes
5:28
Concept: Getting started
1:44
Concept: Alembic - the manual version
3:09
Concept: auto-generating changes
1:50
User input and HTML forms
49:19
The basics of HTML input
3:14
GET-POST-Redirect pattern
2:36
Register for the site (getting started)
3:13
Registration form
1:43
A little design for the register form
4:45
Register POST action
2:43
Getting the submitted values
5:08
Creating the user
6:59
Login form
1:08
Login code
3:20
Creating a user session (cookies)
7:16
Navigation items based on user's session
2:54
One source of data
4:20
Client and server-side validation
33:30
The motivation for viewmodels
2:50
Viewmodel base class
4:15
Using a viewmodel
3:18
The register viewmodel
10:24
Concept: Viewmodel
1:40
Simplified view methods
1:23
Viewmodel data exchange
1:44
Server-side validation with Viewmodels
1:36
Client-side validation with HTML5
4:54
Concept: Client-side validation with HTML5
1:26
Testing web apps
53:04
Why write tests (web)
2:09
Special challenges of the web
2:32
3 types of web unit tests
3:08
Organizing your tests
2:59
Getting started with tests
3:45
Testing the register viewmodel
5:49
Avoiding the database call on register
3:26
Testing registration when inputs are invalid
2:25
Concept: Testing view models
1:34
Testing view methods
5:27
Concept Testing view methods
3:47
Integrated tests
5:39
The rest of the tests
2:28
Running tests outside of PyCharm
2:10
Concept: Testing the full web app
1:02
Pareto principle and testing with sitemaps
4:44
Deployment
40:10
Deployment overview and topology
3:45
02-creating-our-linux-server
5:15
The setup script and config files
3:12
Configure the server
7:47
Make the virtual environment always active
1:44
Setting up our code
2:51
Running under uWSGI
3:28
uWSGI as a service
2:03
Running in nginx
3:29
Adding SSL with Let's Encrypt
3:57
Concept: uWSGI
1:20
Concept: nginx
1:19
MongoDB edition
42:08
Introduction to the NoSQL version
1:42
Not a MongoDB course
0:55
How document databases work
1:14
Connecting to MongoDB
4:55
The user entity with mongoengine
3:41
Saving a user
3:24
The rest of the entities
1:44
Rewriting our queries
6:00
Fixing the login
2:26
Importing the data from SQL to Mongo
3:21
Home page cleanup
4:51
Package details cleanup
3:31
Concepts: MongoEngine and MongoDB
4:24
Course conclusion
15:12
You've done it!
0:41
Creating a new Flask app
1:00
Jinja2 templates and dynamic HTML
1:43
Layout pages
0:57
Routes
1:35
Themes
0:44
Querying data
1:09
Database migrations
0:38
GET-POST-Redirect
1:16
viewmodels
1:29
Testing web apps
1:03
Deployment
1:18
MongoDB edition
0:54
git the source code
0:23
Thanks and goodbye
0:22
Buy for $59 + tax Bundle and save 85% Team Gift

Questions? Send us an email: contact@talkpython.fm

Talk Python's Mastodon Michael Kennedy's Mastodon