Refresh Data in Plotly without the use of Jupyter Notebooks

I have spent a lot of time looking for something that can update a Plotly Scattergeo (world map) without restarting the page and without the use of Jupyter Notebooks/Widgets.

Essentially I would like to have a โ€œbuttonโ€ Filter refresh my dataset . For example, execute a function foo on a button click and modify the dataset which would then be reflected on the currently drawn figure.

Here is a minimum working example:

import plotly.graph_objects as go
from typing import Dict, List, Tuple

data = [((-79.63059998, 43.67720032),(55.36439896, 25.25279999)),
          ((126.4509964, 37.46910095), (12.2388889, 41.8002778)),
          ((31.40559959, 30.12190056),(-0.461941, 51.4706))]

data = [ ((seg[0][1], seg[1][1]), (seg[0][0], seg[1][0])) for seg in data]

fig = go.Figure()

# generate all flight segments on a Scattergeo (world map)
for lat, lon in data:
    fig.add_trace(
        go.Scattergeo(
            lat=lat,
            lon=lon,
            mode='lines',
            line=dict(width=1, color='red')
        ),
    )

# draw the plotly figure 
fig.update_layout(
    title_text='Flight Simulator',
    showlegend=False,
    geo=dict(
        resolution=110,
        showland=True,
        showlakes=True,
        landcolor='rgb(204, 204, 204)',
        countrycolor='rgb(204, 204, 204)',
        lakecolor='rgb(255, 255, 255)',
        projection_type="equirectangular",
        coastlinewidth=2,
        lataxis=dict(
            range=[-90, 90],
            showgrid=True,
            dtick=10
        ),
        lonaxis=dict(
            range=[-180, 180],
            showgrid=True,
            dtick=20
        ),
    )
)

# adds the initial filters
fig.update_layout(
    updatemenus=[
        go.layout.Updatemenu(
            active=0,
            type="buttons",
            direction="right",
            buttons=list([
                dict(label="Reset",
                     method="restyle",
                     args=[{"visible": [segment for segment in data]}]
                     ),
                dict(label="Filter",
                     method="restyle",
                     args=[{"visible": [segment for segment in data]}]
                     ),
                ]),
            pad={"r": 10, "t": 30, "b": 10},
            showactive=True,
            x=0.90,
            xanchor="right",
            y=1.15,
            yanchor="top"
        ),
    ])

# display the figure to the screen
fig.show()

If a restart of the page is required, can it re-draw on the same plot on that localhost instance?