Thanks for the clarification. I am using the multipage support introduced in Dash 2.5. Last week, we had a page which was not working, which broke the whole app. I am simulating this issue (an AttributeError
in the layout()
function of one of the pages).
(relevant) code looks as follows:
app.py
app = dash.Dash(
__name__,
suppress_callback_exceptions=True,
meta_tags=[{
'name': 'viewport',
'content': 'width=device-width, initial-scale=1, shrink-to-fit=no'
}],
title=routing.BASE_TITLE,
url_base_pathname='/dashboard/',
update_title=None,
use_pages=True
)
server = app.server
# Use HTTPS when deployed
server.config['PREFERRED_URL_SCHEME'] = 'https'
server.wsgi_app = ProxyFix(server.wsgi_app)
app.index_string = """
<!DOCTYPE html>
<html>
<head>
{%metas%}
<!-- Font -->
<link href='https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap' rel='stylesheet'>
<title>{%title%}</title>
{%favicon%}
{%css%}
</head>
<body>
{%app_entry%}
<footer>
{%config%}
{%scripts%}
{%renderer%}
</footer>
</body>
</html>
"""
@server.errorhandler(500)
def internal_error(error):
return render_template('500.html')
base.html
<!DOCTYPE html>
<html lang="nl" class="h-100">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Title -->
<title>{% block title %} {% endblock %}</title>
<!-- Font -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">
<!-- CSS Front Template -->
<link rel="stylesheet" href="/dashboard/assets/build/theme.css">
<!-- Favicon -->
<link rel="icon" type="image/x-icon" href="/dashboard/assets/favicon.ico">
</head>
<body class="d-flex align-items-center min-h-100">
<header id="header" class="navbar navbar-expand navbar-light navbar-absolute-top">
<div class="container-fluid">
<nav class="navbar-nav-wrap">
<a class="navbar-brand" href="/">
<span class="navbar-brand-text-logo">/span>
<span class="navbar-brand-text-logop-1"></span>
</a>
<div class="ms-auto">
{% if user %}
<a class="link link-sm link-primary" href="/logout">
<em class="bi-chevron-right small ms-1"></em>
</a>
{% else %}
<a class="link link-sm link-primary" href="">
<em class="bi-chevron-right small ms-1"></em>
</a>
{% endif %}
{% block navbar %} {% endblock %}
</div>
</nav>
</div>
</header>
<main id="content" role="main" class="flex-grow-1">
{% block content %} {% endblock %}
</main>
<script src="/dashboard/assets/static/js/theme.min.js"></script>
</body>
</html>
500.html
{% extends "base.html" %}
{% block title %}Error 500{% endblock %}
{% block content %}
<div class="container">
<div class="row">
<div class="d-flex justify-content-center align-items-center min-vh-lg-100">
<div class="flex-grow-1 mx-auto" style="max-width: 30rem;">
<div class="text-center mb-5 mb-md-7">
<h1 class="h2 mb-4"></h1>
<dl>
<div class="alert alert-danger" role="alert">
</div>
</dl>
</div>
<div class="d-grid mb-3">
<a href='{{ url_for('index') }}' class="btn btn-primary btn-lg text-white"></a>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
Exception:
ERROR:main:Exception on / [GET]
Traceback (most recent call last):
File "pat\to\repo\venv\lib\site-packages\flask\app.py", line 2077, in wsgi_app
response = self.full_dispatch_request()
File "pat\to\repo\venv\lib\site-packages\flask\app.py", line 1518, in full_dispatch_request
self.try_trigger_before_first_request_functions()
File "pat\to\repo\venv\lib\site-packages\flask\app.py", line 1570, in try_trigger_before_first_request_functions
self.ensure_sync(func)()
File "pat\to\repo\venv\lib\site-packages\dash\dash.py", line 2079, in router
[
File "pat\to\repo\venv\lib\site-packages\dash\dash.py", line 2080, in <listcomp>
page["layout"]() if callable(page["layout"]) else page["layout"]
File "pat\to\repo\app\pages\my_account\my_account.py", line 20, in layout
first_name = user.not_existing_attribute or '-'
AttributeError: 'User' object has no attribute 'not_existing_attribute'
INFO:werkzeug:127.0.0.1 - - [10/Oct/2022 15:30:09] "GET / HTTP/1.1" 200 -
ERROR:main:Exception on /dashboard/assets/build/theme.css [GET]
Traceback (most recent call last):
File "pat\to\repo\venv\lib\site-packages\flask\app.py", line 2077, in wsgi_app
response = self.full_dispatch_request()
File "pat\to\repo\venv\lib\site-packages\flask\app.py", line 1518, in full_dispatch_request
self.try_trigger_before_first_request_functions()
File "pat\to\repo\venv\lib\site-packages\flask\app.py", line 1570, in try_trigger_before_first_request_functions
self.ensure_sync(func)()
File "pat\to\repo\venv\lib\site-packages\dash\dash.py", line 2079, in router
[
File "pat\to\repo\venv\lib\site-packages\dash\dash.py", line 2080, in <listcomp>
page["layout"]() if callable(page["layout"]) else page["layout"]
File "pat\to\repo\app\pages\my_account\my_account.py", line 20, in layout
first_name = user.not_existing_attribute or '-'
AttributeError: 'User' object has no attribute 'not_existing_attribute'
INFO:werkzeug:127.0.0.1 - - [10/Oct/2022 15:30:09] "GET /dashboard/assets/build/theme.css HTTP/1.1" 200 -
ERROR:main:Exception on /dashboard/assets/static/js/theme.min.js [GET]
Traceback (most recent call last):
File "pat\to\repo\venv\lib\site-packages\flask\app.py", line 2077, in wsgi_app
response = self.full_dispatch_request()
File "pat\to\repo\venv\lib\site-packages\flask\app.py", line 1518, in full_dispatch_request
self.try_trigger_before_first_request_functions()
File "pat\to\repo\venv\lib\site-packages\flask\app.py", line 1570, in try_trigger_before_first_request_functions
self.ensure_sync(func)()
File "pat\to\repo\venv\lib\site-packages\dash\dash.py", line 2079, in router
[
File "pat\to\repo\venv\lib\site-packages\dash\dash.py", line 2080, in <listcomp>
page["layout"]() if callable(page["layout"]) else page["layout"]
File "pat\to\repo\app\pages\my_account\my_account.py", line 20, in layout
first_name = user.not_existing_attribute or '-'
AttributeError: 'User' object has no attribute 'not_existing_attribute'
INFO:werkzeug:127.0.0.1 - - [10/Oct/2022 15:30:10] "GET /dashboard/assets/static/js/theme.min.js HTTP/1.1" 200 -
ERROR:main:Exception on /dashboard/assets/favicon.ico [GET]
Traceback (most recent call last):
File "pat\to\repo\venv\lib\site-packages\flask\app.py", line 2077, in wsgi_app
response = self.full_dispatch_request()
File "pat\to\repo\venv\lib\site-packages\flask\app.py", line 1518, in full_dispatch_request
self.try_trigger_before_first_request_functions()
File "pat\to\repo\venv\lib\site-packages\flask\app.py", line 1570, in try_trigger_before_first_request_functions
self.ensure_sync(func)()
File "pat\to\repo\venv\lib\site-packages\dash\dash.py", line 2079, in router
[
File "pat\to\repo\venv\lib\site-packages\dash\dash.py", line 2080, in <listcomp>
page["layout"]() if callable(page["layout"]) else page["layout"]
File "pat\to\repo\app\pages\my_account\my_account.py", line 20, in layout
first_name = user.not_existing_attribute or '-'
AttributeError: 'User' object has no attribute 'not_existing_attribute'
INFO:werkzeug:127.0.0.1 - - [10/Oct/2022 15:30:10] "GET /dashboard/assets/favicon.ico HTTP/1.1" 200 -
If there is any more information needed, please let me know!