Hi Dash Community,
I have an html.Table that I want to update every X minutes. I have seen a lots of posts on how to update a data_table but none about html.Table.
import sys
import dash
from dash.dependencies import Output, Input
import dash_core_components as dcc
import dash_html_components as html
import plotly.express as px
import dash_table
import pandas as pd
from data import SITES
from dataframe import create_dataframe
EXTERNAL_STYLESHEETS = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
DF = create_dataframe(SITES)
# Creation of my html.Table that I want to update every X minutes
def Table(dataframe):
rows = []
for i in range(len(dataframe)):
row = []
for col in dataframe.columns:
value = dataframe.iloc[i][col]
if type(value) is list:
cell = html.Td(
html.A(href=value[1], children=value[0]))
else:
cell = html.Td(children=value)
row.append(cell)
rows.append(html.Tr(row))
return html.Table(
# Header
[html.Tr([html.Th(col) for col in dataframe.columns])] +
rows
)
# Table is called here to display it but never updated
def create_app():
app = dash.Dash(__name__, external_stylesheets=EXTERNAL_STYLESHEETS)
app.layout = html.Div(
[
html.Div(
[
html.H1(
children="Dashboard",
style={"display": "flex",
"justifyContent": "center"}
)
]
),
html.Div(
[
html.H2(
children=Table(DF)
)
],
style={"display": "flex",
"justifyContent": "center"},
)
]
)
return app
def main():
app = create_app()
app.run_server(debug=False)
return app
if __name__ == "__main__":
sys.exit(main())
Thx a lot !