Running dash app from Flask app: Error AttributeError: 'NoneType' object has no attribute 'traverse'

Actually i am trying to integrate dash app with flask app. Dash app itself is running successfully. But when i add home page using flask app it stopped working. Do not know what is correct why to combine both apps together.
Actual idea is :
First page will be rendered using flask app having input box asking user to enter their auth token and click on submit button it will open second page dash plotly(Dashboard page)

Please assist me in solving this error. I am very keen to run dash app using flask app.

Files as below:

import dash
from flask import Flask

server = Flask(name)
#server.config[‘SECRET_KEY’] = ‘dev’
wsgi_app = server.wsgi_app
app = dash.Dash(name, server=server)
#app = dash.Dash()
#server = app.server
app.config.suppress_callback_exceptions = True

from flask import render_template, flash, redirect, url_for, request
from wtforms import Form, TextField, TextAreaField, validators, StringField, SubmitField
from app import server, app
import figures
#App config.
DEBUG = True
#app = Flask(name)
server.config[‘SECRET_KEY’] = ‘dev’

class ReusableForm(Form):
name = TextField(‘Name:’, validators=[validators.required()])

def load_dash(name):
return figures.dash_page(name)
#return ‘welcome %s’ % name

@server.route("/", methods=[‘GET’, ‘POST’])
def hello():
form = ReusableForm(request.form)

if request.method == 'POST':

    if form.validate():
        return redirect(url_for('load_dash', name = token))
        # Save the comment here.
        #flash('Hello ' + name)
        flash('All the form fields are required. ')

return render_template('index.html', form=form)

if name == “main”:

from app import app
import dash_core_components as dcc
import dash_html_components as html

#app = dash.Dash()

def dash_page(value):
#app = dash.Dash() #pylint: disable=invalid-name
app.layout = serve_layout(value)
return app.layout

def serve_layout(value):
return html.Div(children=[
html.H1(children=‘Hello Dash’),

        Dash: A web application framework for Python.

            'data': [
                {'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
                {'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': u'Montréal'},
            'layout': {
                'title': 'Dash Data Visualization'

if name == ‘main’:


Reusable Form Demo {% with messages = get_flashed_messages(with_categories=true) %} {% if messages %}
    {% for message in messages %}
  • {{ message[1] }}
  • {% endfor %}
{% endif %} {% endwith %} {{ form.csrf }}
        <div class="input text">
            {{ }} {{ }}

        <div class="input submit">
                          <input type="submit" value="Submit" />
1 Like

Have you tried adding the route where the dash app will be served to the Dash instance?

app = dash.Dash(name, server=server, url_base_pathname='/dash)

1 Like