I want to be able to run my dash app from my flask app when I go to a specific url '/dash'. However I get the following error. 'TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.'
flaskapp.py
app = Flask(__name__)
@app.route('/')
def index():
return 'Welcome!'
@app.route('/dash')
def dash_chart():
dashapp.start() # Run the dash app
if __name__ == "__main__":
app.run(debug=True)
dashapp.py
def start():
app = dash.Dash()
app.layout = html.Div('Hello World')
if __name__=='__main__':
app.run_server(debug=True)
If I make the following change to my flaskapp.py,
server = flask.Flask(__name__)
app = dash.Dash(__name__, server=server, url_base_pathname='/dashapp') #Results in an error
@server.route('/')
def index():
return 'Welcome!'
@server.route('/dash')
def dash_chart():
return flask.redirect('/dashapp')
if __name__ == "__main__":
server.run(debug=True)
I get the following error, AttributeError: 'NoneType' object has no attribute 'traverse'