I'm working on a Flask
project and I want to have my index load more contents when scroll.
I want to set a global variable to save how many times have the page loaded.
My project is structured as :
├──run.py
└──app
├──templates
├──_init_.py
├──views.py
└──models.py
At first, I declare the global variable in _init_.py
:
global index_add_counter
and Pycharm warned Global variable 'index_add_counter' is undefined at the module level
In views.py
:
from app import app,db,index_add_counter
and there's ImportError: cannot import name index_add_counter
I've also referenced global-variable-and-python-flask But I don't have a main() function. What is the right way to set global variable in Flask?