-
Notifications
You must be signed in to change notification settings - Fork 0
/
promises.py
39 lines (35 loc) · 1.1 KB
/
promises.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from dash import Dash, dcc, html, Input, Output, dash_table
app = Dash(__name__)
app.layout = html.Div(
[
dcc.Dropdown(
options=[
{
"label": "Car-sharing data",
"value": "https://raw.githubusercontent.com/plotly/datasets/master/carshare_data.json",
},
{
"label": "Iris data",
"value": "https://raw.githubusercontent.com/plotly/datasets/master/iris_data.json",
},
],
value="https://raw.githubusercontent.com/plotly/datasets/master/iris_data.json",
id="data-select",
),
html.Br(),
dash_table.DataTable(id="my-table-promises", page_size=10),
]
)
app.clientside_callback(
"""
async function(value) {
const response = await fetch(value);
const data = await response.json();
return data;
}
""",
Output("my-table-promises", "data"),
Input("data-select", "value"),
)
if __name__ == "__main__":
app.run_server(debug=True)