1

I'd like to have no error message in my app. I don't know where does it comes from? I don't know if it is in my container or out of my container. How can I delete this error message?

Thank you guys :)

app.py


import pandas as pd
import base64

import dash
from dash import html, dcc, callback, Input, Output
from dash.dependencies import State
from dash import dcc
import dash_bootstrap_components as dbc
from dash import html
import dash_labs as dl

from pages.accueil import layout as lay_home
from pages.statistiques import layout as lay_stat
from pages.geostatistiques import layout as lay_geostat

#Read image
img_greenrock ='GREEN-ROCK.jpg'
encoded_imggr = base64.b64encode(open(img_greenrock, 'rb').read())

#Composants de l'application
#Navbar
navbar =dbc.NavbarSimple([
    dbc.NavItem(html.Img(src='data:image/jpg;base64,{}'.format(encoded_imggr.decode()))),
    dbc.NavItem(html.H2("Exploratory Data Analysis")),
    dbc.NavItem(dbc.NavLink("Accueil", href="/", active="exact")),
    dbc.NavItem(dbc.NavLink("Statistiques", href="/page-1", active="exact")),
    dbc.NavItem(dbc.NavLink("Geostastiques", href="/page-2", active="exact")),             
     ])

#Content
content = html.Div(id="page-content")

#My app
app = dash.Dash(__name__,external_stylesheets=[dbc.themes.LUX],use_pages=True,suppress_callback_exceptions=True)

#Structure de l'app
app.layout = dbc.Container([
                          html.Div([ dcc.Location(id="url",refresh=False), 
                          navbar, 
                          content,
                          ]),
              dash.page_container  ],fluid=True)


# Update the pages
@callback(Output('page-content', 'children'),
              [Input('url', 'pathname')])

def display_page(pathname):
    if pathname == '/':
        return lay_home
    elif pathname == '/page-1':
        return  lay_stat
    elif pathname == '/page-2':
        return lay_geostat
    else :
        return '404' 
   

if __name__ == "__main__":
    app.run_server(debug=True)

statistiques.py (all pages are the same for the moment)


import pandas as pd
import base64

import dash
from dash import html, dcc, callback, Input, Output
from dash.dependencies import State
import dash_bootstrap_components as dbc
import dash_labs as dl

layout = dbc.Row(
    [
        dbc.Col([
            html.Label("Emissions of ZINC"),
            dcc.RadioItems(['Low','High'], value='High', id='emissions', labelStyle={'display': 'block'}),
        ], width=2),

        dbc.Col([
            dcc.Graph(id='my-graph', animate=True,
                      animation_options={'transition':{'duration': 750, 'ease': 'cubic-in-out'}}),
        ], width=10)

    ]
)

Layout my running app html page with the error message

CiaPy
  • 25
  • 6

2 Answers2

0

you may want to check out the section on Default and Custom 404 here. It shows you how you can customise the message shown when page is not found.

HAS
  • 1
  • 1
0

You are calling dash.page_container in app.layout, which will display the layout content from one of your registered pages. However, for this to pull a page through you will first need to register statistiques.py by adding the following line:

dash.register_page(__name__)

Until you do this the call to page_container will return the 404 error. For more information have a look at 'Multi-Page Apps and URL Support' on dash.plotly.com:

https://dash.plotly.com/urls

C M
  • 1
  • 1