Dash HTML : this page isn't working

Hello,

I want to display my interface into a HTML page but I have the “this page isn’t working” as output.

Even a really simple code isn’t working. Do you have any clue ? I already tried a lot on Chrome to fix access issues with my browser.

the code that I want to display is this one :

import base64
import datetime
import io

import dash
from dash.dependencies import Input, Output, State
import dash_core_components as dcc
import dash_html_components as html
import dash_table

import pandas as pd

external_stylesheets = [‘https://codepen.io/chriddyp/pen/bWLwgP.css’]

app = dash.Dash(name, external_stylesheets=external_stylesheets)

Dessiner layout

app.layout = html.Div([
dcc.Upload(
id=‘upload-data’,
children=html.Div([
'Drag and Drop or ',
html.A(‘Select Files’)
]),
style={
‘width’: ‘100%’,
‘height’: ‘60px’,
‘lineHeight’: ‘60px’,
‘borderWidth’: ‘1px’,
‘borderStyle’: ‘dashed’,
‘borderRadius’: ‘5px’,
‘textAlign’: ‘center’,
‘margin’: ‘10px’
},
# Allow multiple files to be uploaded
multiple=True
),
dcc.Dropdown(
id=‘cible’,
children=html.Div([
‘Choisir variable cible’,
]),
options=[
#{‘label’: df.columns[i] for i in range(df.shape[1])}
#{‘label’: df.columns[1], ‘value’: ‘MTL’},
#{‘label’: df.columns[2], ‘value’: ‘SF’}
{‘label’:‘data’, ‘value’: ‘data’},
#{‘label’:name, ‘value’: name} for name in df.columns.tolist()
],
multi=False,
style={‘backgroundColor’: ‘#5E3E3E’},
className=‘stockselector’,
value=‘1’
),

dcc.Dropdown(
    id='predire',
    children=html.Div([
        'Choisir variable cible',
    ]),
    options=[
        #{'label': df.columns[i] for i in range(df.shape[1])}
        #{'label': df.columns[1], 'value': 'MTL'},
        #{'label': df.columns[2], 'value': 'SF'}
        {'label':'data', 'value': 'data'},
        #{'label':name, 'value': name} for name in df.columns.tolist()
    ],
    multi=True,
    style={'backgroundColor': '#115E115E115E'},
    className='stockselector',
    value='1'
    ),

html.Div(id='output-data-upload'),
html.Div(id='data')

],
)

def parse_contents(contents, filename):
content_type, content_string = contents.split(’,’)

decoded = base64.b64decode(content_string)
try:
    if 'csv' in filename:
        # Assume that the user uploaded a CSV file
        df = pd.read_csv(
            io.StringIO(decoded.decode('utf-8')))
    elif 'xls' in filename:
        # Assume that the user uploaded an excel file
        df = pd.read_excel(io.BytesIO(decoded))
except Exception as e:
    print(e)
    return html.Div([
        'There was an error processing this file.'
    ])

return df#html.Div([
    #html.H5('chúng ta là chiến sĩ'),
    #html.H6(datetime.datetime.fromtimestamp(date)),
    #html.H1(children=str(df.shape[0])),
    #html.H2(children=str(df.shape[1])),
    #html.H3(children=df.columns),

     #html.Div(children='''
    #Dash: A web application framework for Python.'''),
    
    #html.Div([
    #dcc.Dropdown(
    #id='cible',
    #options=[
        #{'label': df.columns[i] for i in range(df.shape[1])}
        #{'label': df.columns[1], 'value': 'MTL'},
        #{'label': df.columns[2], 'value': 'SF'}
        #{'label':'data', 'value': 'data'},
    #    {'label':name, 'value': name} for name in df.columns.tolist()
    #],
   # multi=True,
   # style={'backgroundColor': '#1E1E1E'},
   # className='stockselector',
   # value='1'
   # ),
   # html.Div(id='dd-output-container'),
   # html.Div(id='output-content')
   # ]
   # ),
    
    
    
   # html.Div([
    #dcc.Dropdown(
     #   id='out-cible',
      #  ),
       # ],style={'width': '20%', 'display': 'inline-block'}
    #),
    #html.Hr(),
    #html.Div(id='display-selected-values'),
    
  
    
    
    
    
    #dash_table.DataTable(
    #    data=df.to_dict('records'),
    #    columns=[{'name': i, 'id': i} for i in df.columns]
    #), 

    #html.Hr(),  # horizontal line

    # For debugging, display the raw contents provided by the web browser
    #html.Div('Variable cible'),
    
    
    
    
    #html.Pre(contents[0:20] + '...', style={
     #   'whiteSpace': 'pre-wrap',
     #   'wordBreak': 'break-all'
    #})
#])

Mise à jour dropdown

@app.callback(Output(‘cible’, ‘options’),
[Input(‘upload-data’, ‘contents’)],
[State(‘upload-data’, ‘filename’)])

def update_output(contents, filename):
options =

if contents:
    contents = contents[0]
    filename = filename[0]
    df = parse_contents(contents, filename)
    options=[{'label':name, 'value': name} for name in df.columns.tolist()]
return options
#if list_of_contents is not None:
 #   children = [
  #      parse_contents(c, n) for c, n in
   #     zip(list_of_contents, list_of_names)] #, list_of_dates)]
   # return children 

if contents is not None:

for c, n in zip(contents, filename):

df = parse_contents(contents, filename)

 #return [{'label':'datlhlhl', 'value': 'dat'}]
#return [{'label': i, 'value': i} for i in name.columns.tolist()]

@app.callback(Output(‘predire’, ‘options’),
[Input(‘upload-data’, ‘contents’)],
[State(‘upload-data’, ‘filename’)])

def update_output(contents, filename):
options =

if contents:
    contents = contents[0]
    filename = filename[0]
    df = parse_contents(contents, filename)
    options=[{'label':name, 'value': name} for name in df.columns.tolist()]
return options

Mise à jour les données

@app.callback(Output(‘output-data-upload’, ‘children’),
[Input(‘upload-data’, ‘contents’)],
[State(‘upload-data’, ‘filename’)])

def update_table(contents, filename):
table = html.Div()

if contents:
    contents = contents[0]
    filename = filename[0]
    df = parse_contents(contents, filename)

    table = html.Div([
        html.H5(filename),
        dash_table.DataTable(
            data=df.to_dict('rows'),
            columns=[{'name': i, 'id': i} for i in df.columns]
        ),
        html.Hr(),
        html.Div('Raw Content'),
        html.Pre(contents[0:200] + '...', style={
            'whiteSpace': 'pre-wrap',
            'wordBreak': 'break-all'
        })
    ])

return table

#@app.callback(Output(‘data’, ‘children’),

[Input(‘output-data-upload’, ‘children’), Input(‘cible’, ‘options’)],

)

#def update_table(contents, options):

table = contents[options.value]

return table

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

Thank you very much.