Reputation: 21
I'm trying to run (locally) a sample dash app code but I'm always getting a mistake while opening the window.
I'm using Jupyter Notebook and sometimes PyCharm for testing. The code I'm running is this:
import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc
import plotly
import plotly.graph_objs as go # for making plot.ly graph objects
from dash.dependencies import Input, Output
from collections import deque
import random
X = deque(maxlen = 20)
X.append(1)
Y = deque(maxlen = 20)
Y.append(1)
app = dash.Dash(__name__)
# Layout
app.layout = html.Div([
dcc.Graph(id = 'live-graph', animate = True),
dcc.Interval(id = 'graph-update', interval = 1000)
])
# Callbacks
@app.callback(Output('live-graph', 'figure'),
[Input('graph-update', 'n_intervals')])
def update_graph(input_data):
X.append(X[X[-1] + 1])
Y.append(Y[Y[-1] + (Y[-1]*random.uniform[-0.1, 0.1])])
data = gp.Scatter(
x = list(X),
y = list(Y),
name = 'Temperature',
mode = 'lines + markers'
)
return {'data':[data], 'layout':go.Layout(xaxis = dict(range = [min(X), max(X)]),
yaxis = dict(range = [min(Y), max(Y)])
)}
if __name__ == "__main__":
app.run_server(host = '0.0.0.0', port = 8050, debug = True)
I already tried changing the port to 8050 and debug = False. Image Error
Upvotes: 2
Views: 3311
Reputation: 6606
If you're using 0.0.0.0:8050
you should be accessing your site at localhost:8050
.
Upvotes: 3