#flask

I saw this code

from flask import g

what is g?

simple google research reveal this

The g name stands for “global”, but that is referring to the data being global within a context. The data on g is lost after the context ends, and it is not an appropriate place to store data between requests. Use the session or a database to store data across requests.

it’s like request: NextRequest. You can populate that with middleware.ts, then it will be accessible by the other.