gaetgu
gaetgu

Reputation: 134

Getting a 500 Internal server error dash with plotly

I am trying to create a dashboard with the python libraries dash and plotly. I have successfully created a static html dashboard, but when I try to add a plotly graph instead of plain html I get a 500 Internal Server Error. My code is as follows:

import dash
import dash_html_components as html
import dash_core_components as dcc
import plotly.graph_objs as go
import numpy as np

app = dash.Dash()

# Creating data

np.random.seed(42)
random_x = np.random.randint(1, 100, 100)
random_y = np.random.randint(1, 100, 100)

data = [go.Trace(
    x = random_x,
    y = random_y,
    mode = 'lines'
)]

layout = go.Layout(title = 'bello')


app.lyaout = html.Div([dcc.Graph(id = 'lineplot', figure = {'data': data, 'layout': layout})])

if __name__ == '__main__':
    app.run_server()

This outputs this when I try to access the webpage:

raise exceptions.NoLayoutException(
dash.exceptions.NoLayoutException: The layout was `None` at the time that `run_server` was called.
Make sure to set the `layout` attribute of your application
before running the server.

Any help is greatly appreciated!

Upvotes: 0

Views: 2158

Answers (1)

Tejas Sarade
Tejas Sarade

Reputation: 1212

I guess you already figured out, it is just a typo error on line 24. It should be app.layout instead of app.lyaout.

(not related to this question): By the way, it is a good practice not to have space around = in named parameters/keyword argument, unlike assignment operator =.

e.g.

random_x = np.random.randint(1, 100, 100) // assignment OK
layout = go.Layout(title = 'bello') // named parameter KO. Should be title='bello'

Upvotes: 1

Related Questions