3

Application and Request Contexts in Flask

 3 years ago
source link: https://www.patricksoftwareblog.com/application-and-request-contexts-in-flask/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Application and Request Contexts in Flask – Patrick's Software Blog

Learning Python Web Application Development with Flask

I wrote two blog posts on TestDriven.io about how the Application and Request contexts are handled in Flask:

The first blog post provides examples of how to the Application and Request contexts work, including how the current_app, request, test_client, and test_request_context can be used to effectively used to avoid pitfalls with these contexts.

The second blog post provides a series of diagrams illustrating how the Application and Request contexts are processed when a request is handled in Flask. This post also dives into how LocalStack objects work, which are the objects used for the Application Context Stack and the Request Context Stack.

2 Comments

  1. 6f40c326b4a25c302d5c2babd999b618?s=120&d=mm&r=g
    Almir Campos

    February 16, 2021 at 5:47 am

    Hi, Patrick.

    I just took a look at the two articles after a couple of hours trying to better understand the differences among flask.g, flask.session, flask.context_app, and flask.request.

    My conclusion is that the articles (especially the second one) deserve one or more Oscars, although I’m still trying to complete the big picture related to those topics.

    I’m about to complete an intermediate course in Python, Flask, etc. Do you have any plans to offer a little more advanced course about theses topics?

    I confess that what really got me in your explanations were the diagrams with the flows providing a high-level context before digging into the programming details.

    Thank you very much for sharing!

    • 23c19549c9345123d395e05f5eff4e35?s=120&d=mm&r=g
      [email protected] (Post author)

      February 16, 2021 at 3:06 pm

      So happy to hear that the blog posts were helpful in understanding the contexts in Flask!

      I have a Flask course on TestDriven.io: Developing Web Applications with Python and Flask

      I would say that gets to an intermediate-level of concepts in Flask. Are there any particular topics in Flask that you would like to see covered (I’m always looking for new ideas for blog posts!)?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Comment

Name *

Email *

Website


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK