Flask Mega-Tutorial Update: Flask 2.0 and more!

Posted by
on under

I'm excited to share that I've completed a revision of the Flask Mega-Tutorial to keep it in line with new releases of Flask, Python and third-party dependencies.

Flask Mega-Tutorial

To celebrate this update, you can purchase the paid version of this course with a $10 USD discount (this offer is valid through the rest of July 2021). If you are interested in this offer, use the FLASK2 promotional code at checkout, or click here to go directly to the order page with the coupon added. Thank you!

What's in this Update?

While I've made changes in every chapter, below is a list of some of the most interesting updates:

  • Tested to work well with the new Flask 2 release (as well as remaining compatible with Flask 1.x releases)
  • Tested to work well with the 3.6, 3.7, 3.8 and 3.9 releases of Python.
  • All dependencies upgraded to their latest official versions.
  • The updated code has been pushed to the GitHub repository.
  • The FLASK_DEBUG environment variable was replaced with the more modern FLASK_ENV.
  • The importance of the .flaskenv file is more clearly stated.
  • Recommend SendGrid as an alternative email service with a decent free email sending quota.
  • Fixed backwards incompatible changes in the pyjwt package.
  • Switched to the langdetect package for language detection.
  • Upgraded Ubuntu to 20.04 in Linux deployment chapter.
  • Addressed issues with Heroku's Postgres database and SQLAlchemy 1.4.
  • Solved issues with recent releases of the pymysql package requiring the cryptography package to be installed as well.

There is one aspect of the tutorial that is still in need of an update: the use of the Flask-Bootstrap extension. Unfortunately this extension has not been updated in a long time, and it continues to require version 3 of the Bootstrap CSS framework, which is now two major releases old. While there are a few forks of Flask-Bootstrap that implemented support for Bootstrap 4, there are currently none that I know of that support Bootstrap 5. Out of the Bootstrap 4 forks, most are already unmaintained, or else they don't have a clear path to Bootstrap 5. Given that there are no worthy successors to Flask-Bootstrap, I have decided to continue using this old version, which continues to work well, with the caveat that it keeps the user interface stuck on Bootstrap 3. I will continue to monitor this and update the Bootstrap chapter when a good alternative to Flask-Bootstrap appears.

How to Get this Update

The update to the tutorial is available right now on this blog. This continues to be freely available to everyone.

If you have purchased the paid version from my Courses page, first of all thank you so much for your support, and second, you can find the updated ebook downloads and text of the tutorial in your course page. Note that most of the updates are minor in nature, so at this time I have not made updates to the video material.

Become a Patron!

Hello, and thank you for visiting my blog! If you enjoyed this article, please consider supporting my work on this blog on Patreon!

41 comments
  • #1 Ken Hommel said

    Thank you for the tutorial, it's amazing!

    What do you think of using structured logging? I'm looking into building RESTful web services, and I think structured logging is essential. "structlog" seems like a good solution, but integrating it with Flask seems extremely difficult. Have you ever dealt with this issue?

    Thanks again,
    Ken Hommel

  • #2 Varoon said

    Thank you for updating the course, I still use the material. I hoped that Flask-Bootstrap would have been updated. Never the less good stuff.

  • #3 Miguel Grinberg said

    @ Ken: I haven't done work with structlog recently, but have used it in the past. What is the difficult aspect to integrate with Flask? Can't you just use structlog on its own? I don't recall having to do any integration, I just imported it and used it. Flask does not interfere with it.

  • #4 Alex Zh said

    Hi Miguel, thank you for all the work that you've done for Flask learners like myself!

    I'm curious, what is the difference between the free tutorial available on the blog vs the paid course on your website vs the Udemy course?

  • #5 Miguel Grinberg said

    @Alex: the version of the tutorial in my courses page includes the written tutorial, a video walkthrough of all of it (11+ hours of video) and ebook version of the written material. The version on Udemy has just the video material. The version of the tutorial on this blog has just the written content.

  • #6 G said

    Awesome stuff! Thanks for updating it. This is still the gold standard for flask development. Are you considering adding the testing on the v2 as well?

  • #7 Miguel Grinberg said

    @G: I haven't removed anything related to testing for this revision.

  • #8 T said

    Is there a chance to see an OIDC or OAuth integration soon?

  • #9 Shahrukh said

    Is there a way to see all the changes made to the Github repository? For example, I see that the requirements.txt file has been updated with Flask 2.0.1 but when I do the compare, it does not show when it was added, but instead, I see that 3 new packages were added. I know I'm missing something but can't seem to figure it out.

  • #10 Miguel Grinberg said

    @T: As part of this tutorial? I'm not planning to extend it with that. But I have written about integrating Flask with OAuth on this blog, that article is still up to date, I just used that code in a new project recently.

  • #11 Miguel Grinberg said

    @Shahrukh: the git repository is not created in a standard way with changes added at the end, I have rebased every comment with the changes required. Unfortunately this prevents you from seeing the specific changes I've made as part of this revision. My main goal is to allow people to see how the project grows from one chapter to the next, so the commits are really intended to give you that view into the project.

  • #12 Rogerio said

    Congrats!
    You are a key player on flask community.

  • #13 Alex said

    Hi Miguel, is your article for adding flask to serve Https still relevant if someone wants to add that for this course?

  • #14 Miguel Grinberg said

    @Alex: Yes, the HTTPS article is also up to date.

  • #15 Murat said

    Hi Miguel

    I have been following your work for quiet sometime and I am also one of your students. I have been learning a lot from you. I would like to take this opportunity to thank you for your amazing work and being a highly valuable teacher!

  • #16 Andrey said

    Hello Miguel and thank you for your work!
    Is there a way to get previous version of this tutorial?

  • #17 Miguel Grinberg said

    @Andrey: No, sorry.

  • #18 Gavin said

    Miguel, thank you for your tutorials - they are very useful. in Chapter 22 you note that RQ doesn't work on Windows without a Unix emulation layer like Cygwin or WSL. Do you know of anywhere to find walkthroughs for that, or alternatively, what is the simplest path forward for Background Jobs for Windows users? Thanks!

  • #19 Miguel Grinberg said

    @Gavin: After you install WSL, you have a Unix environment that is very close to the real thing. You can do this entire tutorial under one of these using the instructions for Linux, without any special or additional steps. As far as background jobs running natively on Windows, Celery version 3 used to support Windows, but support was removed in the current version 4.

  • #20 Gavin said

    Hi Miguel
    Bought your tutorial a couple of years ago and have used your teachings as a basis for a few Flask projects now. I was wondering what impact an upgrade of all dependencies, including Flask, to latest version would do to an existing project based on flask 1.1.2 (or any other 1.x.x. Do you have advice on particular fixes that may be necessary before I embark on a trial and error approach?

  • #21 Miguel Grinberg said

    @Gavin: Most things will be okay as long as you don't leave any of your dependencies behind. For example, upgrade Flask to 2.x should be done alone with all the extensions, which presumably have also been upgraded to be compatible with Flask 2. There is always the chance that you have an extension or other package that hasn't been updated, but the chances are small, because the upgrade from Flask 1 to Flask 2 does not have that many breaking changes.

    At the end of the day, the only way to find out is to do the upgrade and test.

  • #22 Andre Jansen said

    Best,
    I have purchased on the old site only the pdf version.
    Can I then become an updated version off the pdf or must I purchase all including the videos?

    Andre

  • #23 Miguel Grinberg said

    @Andre: if you log in to the old site, you can access a link to set up your account in the new courses site, obviously without paying anything.

  • #24 Bilal said

    How does the content of this tutorial book compare with the o'reilly 2nd edition of your Flask book? (does it cover the same topics in more or less details?)

  • #25 Miguel Grinberg said

    @Bilal: have you compared the table of contents of both? That's the best way to see what topics are in one and the other. The core topics are in both, but the mega-tutorial covers more non-Flask topics, that you may or may not be interested in.

Leave a Comment