SOLUTION:
I have updated to new dash 2.9.2 (this version now allows using same output in multiple callbacks see
Dash 2.9.2 Released - Partial Property Updates with Patch(), Duplicate Outputs, dcc.Geolocation, Scatter Group Attributes and More - Dash Python - Plotly Community Forum), so the main page became:
from dash import Dash, register_page, dcc, html, Input, Output, ctx
from dash.exceptions import PreventUpdate
from pages import login, labelsAnalisys
##from threading import Timer
##from time import time
##external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = Dash(
__name__,
use_pages=True,
## prevent_initial_callback="initial_duplicate", # é necessário para multiplos outputs
)#, external_stylesheets=external_stylesheets)
app.layout = html.Div(
children = [
dcc.Location(id='url', refresh=False),
login.layout
],
id="main-container"
)
@app.callback(
Output("main-container", 'children'),
Output("url", "pathname", allow_duplicate=True),
Input('user-input', 'value'),
Input('password-input', 'value'),
Input('login-button', 'n_clicks'),
prevent_initial_call=True,
)
def login_state(input_user_input, input_password_input, login_button):
if (input_user_input != None) and (input_password_input != None) and (ctx.triggered_id == "login-button"):
return(
html.Div(
children=[
dcc.Location(id='url', refresh=False),
html.Div(
children=[f"LOGADO COM SUCESSO"],
id='login-message-label',
style={"text-align":"center"}
),
html.Div("LOGADO"),
dcc.Interval(
id='interval-component',
interval=1000, # update every 1000 milliseconds (1 second)
n_intervals=0
)
],
id="main-container-1"
),
"analitics"
)
else:
raise PreventUpdate
@app.callback(
Output('login-message-label', 'children'),
Input("interval-component", 'n_intervals')
)
def login_session_time(n):
return(
f"LOGADO COM SUCESSO HÁ {n} SEGUNDOS"
)
@app.callback(
Output('main-container-1', 'children'),
Output("url", "pathname"),
Input("interval-component", 'n_intervals')
)
def back_login_page(n):
if n == 5:
return(
login.layout, "/"
)
else:
raise PreventUpdate
if __name__ == '__main__':
app.run_server(debug=True)