Bring Drag & Drop to Dash with Dashboard Engine. 💫 Learn how at our next webinar!

How to read data from Dash html.Div in a non-Dash application

My code is very simple. It prints the current time to a URL location. Now, I’d like the time data to be read by another non-Dash application.

app.layout = html.Div([
    # represents the URL bar, doesn't render anything
    dcc.Location(id='url', refresh=False),
    html.Div(id='page-content')
])


@app.callback(dash.dependencies.Output('page-content', 'children'),
              [dash.dependencies.Input('url', 'pathname')])
def display_page(pathname):
    if pathname=="/page-2":
        x = datetime.datetime.now()
        print(pathname)
        return html.Div([
            html.H3(f"The datatime is {x}")
        ])

As of now, I can print the time, and this is no problem! But how to read from another application?

This is the simple example code. In my actual application, some JSON data will be continuously updated and posted to /page-2 and would be read by another application.