How to Solve NameError: name ' g' is not defined -- flask

Solution: Import the 'g' module

# Add the following line to the top of your code
from flask import  g

 

For more information:
flask g