How to reload data every time page is reloaded when app is passed as parameter?

If you want to reload layout every page reload you do this:
app.layout = myfunction

NOTE: calling my function without parenthesis, this would be wrong:
app.layout = myfunction()

But what if I want to call that function with parameters?
app.layout = myfunction????

I’ve made a workaround by creating a dummy function like this

def serve_layout():
    return layout(app) # I pass app to use app.callbacks

app.layout = serve_layout

HOWEVER, I am getting lots of errors about callbacks telling me that there are duplicate callbacks, which there really aren’t.


In the callback for output(s):
Output 0 ( is already in use.
Any given output can only have one callback that sets it.
To resolve this situation, try combining these into
one callback function, distinguishing the trigger
by using `dash.callback_context` if necessary.

source code:

import dash
from layout import layout # layout is where i define all layout logic/ components

def serve_layout():
    return layout(app)

app = dash.Dash(__name__)

app.layout = serve_layout
app.title = 'Example app'
if __name__ == "__main__":

I’ve made a workaround by following documentation guidelines for multi paged apps