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

Solution: Import the 'PY2' module

# Add the following line to the top of your code
from flask._compat import PY2

 

For more information:
flask PY2