Developing Web Applications with Python and Flask
Developing Web Applications with Python and Flask!
This course teaches the fundamentals of Flask by building a full-featured web application. Each chapter builds upon itself to achieve the goal of developing a stock portfolio app.
What will you build?
In this course, you'll build an app for tracking stock portfolios. You can think of it as a basic version of a brokerage site like Fidelity or TD Ameritrade. The app provides user management functionality (e.g., registration, login/logout, password reset) so that multiple users can access the app. After registering, users will be able to view and add new stocks to their portfolio.
An example of the Flask application that you'll be creating in this course can be found at:
Here are the key concepts that you will learn in each part of this course:
Part 1 - Flask Fundamentals
- Utilize Python 3 and Flask to create a web application
- Create view functions for handling requests to specific URLs (routes)
- Utilize the Jinja templating engine to add logic when generating HTML
- Process form data in a view function using the
- Store and retrieve data in a session for use between requests
- Write tests using pytest
- Utilize static files (sylesheets, images) for enhancing the look and feel of the app
- Create flash messages for displaying information to the user
- Log messages to a file to understand the operations of the web app
Part 2 - Structure
- Organize a Flask project into blueprints
- Create multiple configurations for your development, production, and testing environments
- Create an application factory function for initializing a Flask app
- Describe the steps for processing a request in Flask
- Explain how the application and request contexts work during request processing
- Utilize fixtures to help initialize the state for running tests
Part 3 - Database
- Create a SQLite database to store data
- Utilize Flask-SQLAlchemy to interact with the SQLite database
- Create custom CLI commands for populating data into the database
Part 4 - User Management
- Utilize TDD to incrementally add functionality to a Flask app
- Handle user registration in Flask
- Explain how to mitigate CSRF and XSS attacks in Flask
- Send emails using Flask-Mail
- Confirm users' email addresses using unique links emailed to them
- Implement 'forgot your password' functionality
- Create a user profile page
Part 5 - Stocks
- Display and add stocks to a user's portfolio
- Utilize monkeypatching to test working with an external API
- Retrieve stock data from an external API
- Display charts of stock prices using Chart.js
Part 6 - Deployment
- Deploy a Flask app to Heroku
- Utilize SendGrid for sending emails in production
Tools and Technologies
As the culmination of this course, we'll deploy the Flask application to the web using Heroku.
This course is intended for people with some experience with Python.
No prior experience with other web frameworks (Django, Pyramid, FastAPI, etc.) is required.
- Current version: 1.1.0
- Last updated: December 15th, 2020
- Author: Patrick Kennedy
What will you learn?
Flask is considered a micro-framework, as it provides the core pieces of functionality needed for a web framework.
The first section of this course focuses on those core pieces:
- View functions
- Jinja templates
- Static files
- Flash messages
Additionally, you'll learn how to write tests for a Flask application using pytest.
The second section of this course focuses on structuring a Flask application using blueprints.
In this section, you'll learn how to create different configurations for different environments -- e.g., development, testing, and production. We'll dive into how the Application Factory design pattern can be applied to Flask to easily create a Flask application as well.
This section also provides a deep-dive into how Flask processes requests and how the application and request contexts are handled during a request.
Finally, you'll learn how fixtures in pytest can help create the initial state for running tests.
The third section of this course focuses on using Flask-SQLAlchemy to:
- create models for the tables in the database
- store and retrieve data in the database
In addition, we'll look at how to create custom CLI commands in Flask to populate the database with data.
Starting with the fourth section of this course, we'll utilize Test-Driven Development (TDD) to incrementally add functionality to the Flask app.
This section focuses on managing the users of the app:
- Registering new users
- Logging users in and out
- Sending emails with Flask-Mail
- Confirming users' email addresses using unique links emailed to them
- Implementing 'forgot your password' functionality
- Presenting a user profile page
In addition, you'll learn about how to mitigate CSRF and XSS attacks.
The fifth section of this course focuses on working with stock data.
We'll look at how to display the stock portfolio for each user and how to add new stocks.
You'll learn about monkeypatching for testing an external API. Then, we'll dive into pulling in stock data from an external API.
This section culminates with creating charts of the historical stock prices using Chart.js.
The sixth section of this course focuses on deploying the app to Heroku and configuring SendGrid for sending emails.
Table of Contents
Table of contents from Developing Web Applications with Python and Flask:
- Setting Up a Flask Project
- Testing with pytest
- Static Files
- Flash Messages
- Application Factory
- Flask Under the Hood
- Pytest Fixtures
- Error Pages
- Database Relationships
- Database Migrations
- Database Testing
- Flask CLI
Get 6 Parts:
- User Model
- User Registration
- Login and Logout
- Sending Email
- Confirming Email Addresses
- Password Reset via Email
- User Profile
- Change Password
- Resend Email Confirmation
- Stock Model
- Adding Stock Data
- Retrieving Stock Data
- Displaying Stock Charts
- Deploying to Heroku
Join our mailing list to be notified about course updates and new tutorials.