简体   繁体   中英

Error while running Dash app locally, "This site can’t be reached"

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

如果您使用的是0.0.0.0:8050您应该在localhost:8050访问您的站点。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM