The Ultimate Flask Course

Video description

Get started with the Flask framework by building six interesting applications

About This Video

  • Get to grips with the framework of Flask and its extensions
  • Discover the process of building and deploying Python-based web applications using Flask
  • Learn how to use Flask extensions to make your applications more powerful

In Detail

Many developers, and even beginners, opt for the Flask framework to build web applications because of its easy-to-understand and well-defined framework. This course will show you how to use the Flask framework's power and its extensions to build powerful and robust web applications.

The course starts by taking you through the process of setting up the Flask environment on your machines. Next, you will understand the Flask basics and templates and learn how to create and connect to a database. In the rest of the course, you will build six interesting Python web applications to dive deep into the concepts of the Flask framework.

By building these applications, you will learn how to create and connect the applications to databases, how to use Flask to process incoming request data, how to build an API with Flask, how to handle user sessions, and how to deploy applications to a server. In addition to this, you will also cover popular Flask extensions, such as Flask-SQLAlchemy, Flask-Bootstrap, Flask-Babel, and learn how these extensions add powerful functionalities to your applications.

By the end of this course, you will be well-versed in the Flask framework and extensions and will have gained the skills to build real-world applications.

Who this book is for

If you are a beginner or an experienced Python developer, who is looking to learn Flask to develop Python web-based applications, this course is for you. Basic knowledge of Python is needed to get started with this course, and prior knowledge of HTML would be an added advantage.

Publisher resources

Download Example Code

Table of contents

  1. Chapter 1 : Flask Basics
    1. Installation on Windows
    2. Two Ways of Running Flask Applications
    3. Installing and Running Hello World
    4. Introduction to Routes
    5. Route Methods
    6. Route Variables
    7. Requesting Query String
    8. Requesting Form Data
    9. Requesting JSON Data
    10. Incoming Request Method
    11. Redirects and url_for
    12. Configuration
    13. Sessions
    14. Debug Mode
  2. Chapter 2 : Templates
    1. Introduction to Templates
    2. Template Variables
    3. Conditionals
    4. Loops
    5. Static Files
    6. Inheritance
    7. Include
  3. Chapter 3 : Database
    1. Creating the Database
    2. Connect to the Database
    3. Queries
    4. Inserting Data
    5. View All Results
  4. Chapter 4 : Food Tracker Application
    1. Demo
    2. Initial HTML Files
    3. Adding Templates
    4. Creating the Database
    5. Adding Database Helpers
    6. Working with the Food Form
    7. Inserting Food Data into the Database
    8. Displaying All Foods in the Database
    9. Inserting the Date
    10. Querying All Dates
    11. Day Screen
    12. Adding Food to the Database
    13. Getting a List of Foods for the Day
    14. Getting Food Totals for the Day
    15. Links
    16. Calculating Totals Per Day
    17. Adding Links
    18. Refactoring
    19. Setting Up Deployment Server on Amazon Lightsail
    20. Deploying to Amazon Lightsail Server
    21. Errata
  5. Chapter 5 : Question and Answer Application
    1. Demo
    2. Overview of Templates
    3. Install and Templates
    4. Database Helpers
    5. Creating the Database
    6. Registering a User
    7. Logging In
    8. Sessions
    9. Common User Functions
    10. Updating Links
    11. Creating Test Users
    12. User Setup Page
    13. Creating a Question
    14. Listing Questions
    15. Answering Question
    16. Home Route Questions
    17. Question Page
    18. Preventing Duplicate Users
    19. Protecting Routes
    20. Protecting Routes by Role
    21. Login Failure Messages
    22. Formatting Queries
    23. Added Link Macro
    24. Base Template
    25. Deploying to Heroku
    26. Converting to Postgres
    27. Static Secret Key on Heroku
  6. Chapter 6 : Member API
    1. Demo
    2. Setting Up the Application and Test with Postman
    3. Adding Database Helpers
    4. Creating the Database
    5. Creating a New Member
    6. Returning a Member after Creation
    7. Getting All Members
    8. Getting One Member
    9. Editing a Member
    10. Deleting a Member
    11. Authentication
    12. Authentication Decorator
    13. Deploying to Python Anywhere
  7. Chapter 7 : Flask-SQLAlchemy
    1. Setting Up a Database and Determining the URI
    2. Installing Flask-SQLAlchemy
    3. Connecting to the Database
    4. Creating a Table
    5. Inserting Data
    6. Updating Data
    7. Deleting Data
    8. Introduction to Queries
    9. Generative Queries
    10. Not Equals and Like
    11. In and Not In
    12. Null and Not Null
    13. And
    14. Or
    15. Order By
    16. Limit
    17. Offset
    18. Count
    19. Inequality
    20. One-to-Many Relationship
    21. One-to-Many Queries
    22. Many-to-Many Relationships
    23. Many-to-Many Queries
  8. Chapter 8 : Flask-WTF
    1. Installing and Setting Up Flask-WTF
    2. Creating a Form
    3. Submitting the Form
    4. Validators
    5. More Fields
    6. Adding an Extra Validator
    7. Changing Labels and Defaults
    8. Prepopulating Data
    9. Populating Obj
    10. More on CSRF
    11. Jinja Macro
    12. Form Inheritance
    13. Field Enclosures
    14. Field List
    15. Deleting Field
    16. Dynamic Forms
    17. Note on JavaScript AJAX
    18. Recaptcha Field
    19. Inline Validators
    20. Information on Other Fields and Validators
    21. Date Fields
    22. Flask-WTF Example
    23. Flask-WTF with Flask-Bootstrap
  9. Chapter 9 : Flask-Bootstrap
    1. Installing and Setting Up Flask-Bootstrap
    2. Blank HTML
    3. Available Blocks
  10. Chapter 10 : Flask-Mail
    1. Configuring Flask-Mail
    2. Setting Up Server and Sending an Email
    3. Notes on Debug
    4. Email Body
    5. Adding More Recipients
    6. Adding Sender Name
    7. Bulk Messages
    8. Attachments
    9. Other Message Parameters
    10. Setting Up Gmail
  11. Chapter 11 : Flask-Migrates
    1. Installing Flask-Migrates and Setting Up an Environment Variable
    2. Creating Database, Adding SQLAlchemy, and Migrating
    3. Creating Table Upgrade in SQLite
    4. Upgrading with SQLite
    5. SQLite Downgrades
    6. Upgrading and Downgrading
    7. MySQL Upgrade and Downgrade
    8. Manually Editing Migration
    9. Dropping Columns in SQLite
  12. Chapter 12 : Flask-Uploads
    1. Installing and Configuring Flask-Uploads
    2. Uploading a Form
    3. Uploading the Image
    4. Allow and Deny
    5. Default Dest
    6. Combining Extensions
  13. Chapter 13 : Flask-Login
    1. Installing and Initializing Flask-Login
    2. Adding User Model
    3. User Loader
    4. Login User
    5. Current User
    6. Log Out a User
    7. Creating a Login Form
    8. Redirecting to the Login Route
    9. Login Message
    10. Redirecting Messages
    11. Remember Me
    12. Fresh Login
    13. Alternative Tokens
    14. Auto Expire
    15. Using MongoDB
  14. Chapter 14 : Flask-Admin
    1. Installing and Setting Up Flask-Admin
    2. Adding User View
    3. Viewing Table with Multiple Columns
    4. Tables with Relationships
    5. Removing a Column from the View
    6. Displaying Primary Key Column
    7. Enabling/Disabling, Creating, Editing, and Deleting
    8. Exporting Table Data
    9. Creating a Modal
    10. Other Attributes
    11. Using on_model_change to Automatically Hash a Password
    12. File Admin
    13. Modifying the Home Template
    14. Modifying Other Views
    15. Creating a New View
    16. URL For
    17. Inline Models
    18. Authentication for Views
    19. Adding Flask-Login
  15. Chapter 15 : Flask-User
    1. Installing and Configuring Flask-User
    2. Creating a Database
    3. Flask-User Sign In and Register Screens
    4. Creating a Protected Page
    5. What Flask-User Does to the Database Record?
    6. Enabling Emails
    7. Modifying Templates
    8. Modifying Email Templates
    9. Changing the After-Register Endpoint
    10. Current User Information
  16. Chapter 16 : Flask-Babel
    1. Installing Flask-Babel
    2. Locale
    3. Dates and Datetime
    4. Marking Words for Translation
    5. Translations
    6. Poedit
  17. Chapter 17 : Flask-Restless
    1. Installing Flask-Restless
    2. Setting Up Models
    3. Creating a Database
    4. Integrating Flask-Restless
    5. GET Requests
    6. GET Specific Items
    7. POST Requests
    8. DELETE Requests
    9. PUT Requests
    10. Limit
    11. Offset
    12. Order By
    13. Searching Queries
    14. In and Not In Operators
    15. Is Null and Is Not Null Operators
    16. Like Operator
    17. Or Queries
    18. Any Operator
    19. Has Operator
    20. Deleting with Queries
    21. Patching with the Queries Bug
    22. Pagination
  18. Chapter 18 : Flask-SocketIO
    1. Installing and Setting Up Flask-SocketIO
    2. Setting Up JavaScript Client
    3. Sending Messages from Client to Server
    4. Sending Messages from Server to Client
    5. Emitting Custom Events
    6. Sending and Receiving JSON
    7. Multiple Clients
    8. Broadcasting Messages
    9. Server Initiated Events
    10. Namespaces
    11. Session IDs
    12. Sending Private Message
    13. Joining a Room
    14. Leaving a Room
    15. Closing a Room
    16. Connecting and Disconnecting
  19. Chapter 19 : Flask-Security
    1. Installing and Setting Up Flask-Security
    2. Creating a Database
    3. Viewing Login and Register Routes
    4. Additional Routes
    5. Login Required and Current User
    6. Roles
    7. Enabling Mail
    8. Custom Emails
    9. Custom Views
    10. Extending the Forms
    11. HTTP Basic Authentication
  20. Chapter 20 : Engage! A Twitter Clone
    1. Overview of Templates
    2. Creating Routes with Templates
    3. Converting Static Resources
    4. Preparing Flask-Migrate and Flask-SQLAlchemy
    5. Creating an SQLite Database
    6. Adding User Model and Creating a Table
    7. Creating the Register Form
    8. Converting the Register Form to WTForm
    9. Testing the Register Form
    10. Adding Error Messages to the Register Form
    11. Handling the Profile Image Upload
    12. Saving the Registration Data to the Database
    13. Creating the Login Form
    14. Creating the Login Route
    15. Finishing the Login Form
    16. Displaying the Profile Information
    17. Creating Tweet Model and Migrating
    18. Creating a Tweet Form
    19. Updating the Timeline to Be Dynamic
    20. Adding Time Since the Creation of a Tweet
    21. First Refactor
    22. Timeline Image and Total Tweets
    23. General Timeline Page
    24. Making a Profile General
    25. Follower Model
    26. Adding a Follow Route
    27. Updating the Follower Count and List of Followers
    28. Creating a Follow Link
    29. Testing the Follow Link
    30. Updating the Timeline Page
    31. Adding Links to User Profiles
    32. Who to Watch Section?
    33. Adding User Timeline Links
    34. Refactoring HTML
    35. Refactoring Navigation
    36. Making Navigation Links Dependent on Login Status
    37. Updating the Timeline Follower Count and Changing the Homepage
    38. Refactoring Views
    39. Refactor Register Template
    40. Conclusion
  21. Chapter 21 : Store Application
    1. Initial Files
    2. Adding the Product Table
    3. Creating the Add Product Form
    4. Adding Products to the Database
    5. Admin Dashboard Product List
    6. Showing the Dollar Amount and Product Counts
    7. Adding Products to the Homepage
    8. The Product Page
    9. Adding Products to the Cart
    10. The Cart Session
    11. Displaying Items in the Cart
    12. Removing Items from Cart
    13. Creating the Order Tables
    14. Creating the Checkout Form – Part 1
    15. Checkout Form - Part 2
    16. Checkout Form - Part 3
    17. Randomizing the Reference
    18. Checkout Screen Cart Details
    19. Managing Pending Orders
    20. Calculating the Order Total
    21. Order Screen
    22. Updating the Stock Totals
  22. Chapter 22 : Forum Application
    1. Overview of the Forum Application
    2. Setting Up the Flask-Security Models
    3. Setting Up the Register Page
    4. Setting Up a User
    5. Login Screen
    6. Thread Model
    7. Saving the Thread Form to the Database
    8. Displaying Threads from the Database
    9. Updating the Thread Model to Include the Date
    10. Thread Page
    11. Creating the Reply Model
    12. Handling Replies
    13. Adding the Last Post's Date
    14. The Profile Page
    15. Adding Links and Wrap Up
  23. Chapter 23 : Weather Application
    1. Introduction
    2. Setting Up the Application
    3. Retrieve API Data
    4. Creating a Database
    5. Adding Cities to the Database
    6. Show Saved City Data
    7. Allow User Save Cities
    8. Install Python-Dotenv
    9. Preventing Duplicate Cities
    10. Preventing Invalid Cities
    11. Message Flashing
    12. Deleting Cities

Product information

  • Title: The Ultimate Flask Course
  • Author(s): Anthony Herbert
  • Release date: September 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781839219924