Hi everybody. I have to update an image in a web page. I am using dcc.Interval to set the time interval and update the image from the url. The frequency is 30 seconds, however the image keeps the same. Why the image is not update? Thanks in advance. I share the code.
app = dash.Dash(external_stylesheets=[dbc.themes.BOOTSTRAP])
app.layout = html.Div([
dcc.Interval(
id=‘sab-images-interval-component’,
interval=30*1000, # 30 seconds
n_intervals=0
),
dbc.Col([
dbc.Row([
dbc.Col(html.Div(id='disp_sab_div'), width=2),
], no_gutters=True, align="center"),
]),
])
@app.callback(
[
Output(component_id=‘disp_sab_div’, component_property=‘children’)
],
[
Input(component_id=‘sab-images-interval-component’, component_property=‘n_intervals’)
]
)
def _updateDispSab(n):
_div =
image_filename = ‘http://179.xx.yy.zz/SBYA/Sab_cam.jpg’
title =‘Sabancay from Chivay’
print(str(dt.datetime.now()))
_div = html.Div([
html.Img(
src=image_filename,
style={
'width': '100%',
}
),
])
return [_div]
if name == ‘main’: