Introduction
The g object in Flask lets you store and share data during a single web request. It helps keep data accessible only while handling that request.
You want to save database connections to reuse during one request.
You need to share user info between different parts of your code during a request.
You want to store temporary data that should not persist after the request ends.
You want to avoid passing many variables between functions handling the same request.