Hello!
I have a multi-page project in Dash.
main.py looks like:
app = Dash(__name__, use_pages=True)
app.layout = dbc.Container([
dash.page_container
], fluid=True
)
pages/home.py looks like:
import dash
from solver import some_function
dash.register_page(__name__, path_template='/company/<id>')
def layout(id=None):
data = some_function(id) # huge amount of data
And finally solver.py:
def some_function(id):
# some code
return data
I want to add caching. I need to add to solver.py:
from flask_caching import Cache
cache = Cache(app.server, config={ ... })
@cache.memoize(timeout=TIMEOUT)
def query_data():
# some code for caching
I donât understand how to use the app variable in another module and I canât find a solution.
As I understand it, there was a similar problem here, but I need to add caching not in main.py.
I tried adding app_flask = Flask(_ name _) to solver.py, but this solution doesnât seem to work and gives errors.