Run a dash app inside a flask app


#1

Hello,
I currently have a flask app and I want to implement a dash app into it. However I’ve been running into multiple errors and I don’t really understand the document for dash deployment. Here is my code

flaskapp.py

server = Flask(__name__) 
@server.route('/dash')
def dash_chart():
	dashapp.start()

if __name__ == "__main__":
	server.run(debug=True)

dashapp.py

def start():
    app = dash.Dash(__name__)
    app.layout = html.Div('Hello World')
    if __name__=='__main__':
        app.run_server(debug=True)

#2

Is there a specific reason to have two separate scripts for this?
Will something like this solve your problem:

server = flask.Flask(__name__)
app = dash.Dash(__name__, server=server)

app.layout = html.Div(
	children=[
            **stuff goes here**
	]
)

if __name__ == '__main__':
	app.run_server(debug=True, port=8050, host='127.0.0.1')
	app.run_server(debug=True)

That’s how I’ve implemented my stuff and it works like a charm. :man_technologist: