Flask g of the object, and the difference between g, session, flash

Use a .g object

g the object designed to store the user information, g is the global full name

Where all the code g target in a request, which may be used are

g object use:

  • Provided:. G variable name = variable value
  • Gets: g.name

Note: g routing a further example, the object can then provided to a route that is subject to g, and can not get the route summarized in b Object g

The difference between the two .g session, flash,

  • session Just set, you can get in any request, no matter how many times you get
  • flash Once set, available on request at any one time, but can only take one
  • g A setting in the route that is acquired only request A routing request, other requests can not be obtained

Guess you like

Origin www.cnblogs.com/pythonywy/p/11604470.html