1.

What is the g object in Flask? How does it differ from the session  object?

Answer»

g is a GLOBAL namespace that can be used to store any data during a SINGLE APP context. A before request HANDLER, for example, may set g.user, which the route and other functions will have access to. In the flask, on the other hand, a session object, which is a dictionary object that HOLDS a key-value pair of the session variables and their associated values, is used to track the session data. To set the session variable to a specified value on the server, use the following syntax. We can use the session to save data for a specific browser. When a user of our Flask app makes more queries while using the same browser, the session data is carried over.



Discussion

No Comment Found