Need urgent help graphing in DASH app

Hello, hoping someone can take a look at my code? I added in the layout and dcc.graph component for the graph to appear using the web browser. What I am missing? I have tried several times and at this point I’d like to at least get something running in the app.

Specifically, I am getting this error :
File “heatmapRNASeqdashv3.py”, line 23
if name == ‘main’:
^
SyntaxError: invalid syntax

-------code starts below
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import plotly.graph_objs as go
import plotly.offline as py

external_stylesheets = [‘https://codepen.io/chriddyp/pen/bWLwgP.css’]
app = dash.Dash(name, external_stylesheets=external_stylesheets)

df = pd.read_csv(
https://gist.githubusercontent.com/schot123/2016d5854a7274eb4126fdd53738a7f9/raw/88e209f02e996150658de093e5551c9c5daab5ba/heatmapRNASeqdash.csv’, index_col=0)

trace = go.Heatmap(z = df.as_matrix().transpose(), y = df.columns, x = df.index)
data=[trace]
fig = go.Figure(data=data)
dcc.graph(fig)

app.layout = html.Div(children=[
html.H1(children=‘Insert header of your Graph Here’),

if name == ‘main’:
app.run_server(debug=True,port=8059)

Try: if __name__ == "__main__": instead

That gives a syntax error:
SyntaxError: invalid syntax

Any other thoughts? It is a basic project to just make a static heatmap interactive and run it in the dash app using the browser. I don’t know what is missing. My github page is publuc if anyone else will take a look or write their own code for this. I will appreciate the help.

You should change if name == ‘main’: to if __name__ == "__main__" . The error message comes from the code below as some parentheses are missing:

app.layout = html.Div(children=[
html.H1(children=‘Insert header of your Graph Here’),

It seems to work fine for me after that.

import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import plotly.graph_objs as go
import plotly.offline as py

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash('Example name', external_stylesheets=external_stylesheets)

df = pd.read_csv(
    'https://gist.githubusercontent.com/schot123/2016d5854a7274eb4126fdd53738a7f9/raw/88e209f02e996150658de093e5551c9c5daab5ba/heatmapRNASeqdash.csv',
    index_col=0,
)

app.layout = html.Div(children=[
    html.H1(children='Insert header of your Graph Here'),
    dcc.Graph(
        id='example-graph',
        figure={
            'data': [go.Heatmap(z = df.as_matrix().transpose(), y = df.columns, x = df.index)],
            'layout': {'title': 'Dash Data Visualization'}
        }
    ),
])

if __name__ == '__main__':
    app.run_server(debug=True, port=8059)

The original code probably had this right. When code is not wrapped in a code block, the underscores are interpreted as strong style formatting (hence why those keywords appear as bold).

One reason why all code snippets posted here should be formatted as code blocks

Ah, yes that makes sense. The syntax error that the op copied made it look like that was the issue.

thank you for the help. I have to look closely at the parenthesis missing but the code finally works now. How to get this to work in a web browser and not in the localserver?