Deploying Dash app as a route on Flask website

I’m trying to create a route on a flask website that is a dash app.
However the app doesn’t load and just says “Loading…” on my local host.

The plan is to deploy the flask website to an AWS elastic beanstalk.

The code is below:

from flask import Blueprint, flash, g, redirect, render_template, request, url_for, Flask
from werkzeug.exceptions import abort
from flaskr.auth import login_required
from flaskr.db import get_db
import os
import dash
import dash_renderer
import dash_core_components as dcc
import dash_html_components as html

server = Flask(__name__)
dash_app = dash.Dash(__name__, server=server, url_base_pathname='/')
dash_app.config.suppress_callback_exceptions = True
dash_app.scripts.config.serve_locally = True
dash_app.layout = html.Div('Hello World')

bp = Blueprint('dashboards', __name__, url_prefix='/dashboards')

@bp.route('/select', methods=['GET', 'POST'])
def index():
    return render_template('dashboards/select.html')

@bp.route('/dash_one', methods=['GET', 'POST'])
def dash_one():
	return dash_app.index()

Here’s what happens when I load the page:

I get “GET /_dash-component-suites/dash_renderer/bundle.js?v=0.12.1 HTTP/1.1” 404 (amongst others as you can see). I am not sure why it can’t find my dash sitepackage?

The url_base_pathname is the “/” before the “_dash-component-suites”

The file structure is below:


It’s pretty much file structure from the flask tutorial.

I want it to load obviously but I don’t know where/what “/_dash-component-suites/” is and how to get the flask website to GET them?

NB: If I comment-out ‘dash_app.scripts.config.serve_locally = True’ I get this error instead (with url_base_pathname=’/dummypath/’):
127.0.0.1 - - [28/May/2018 16:43:44] “GET /dashboards/dash HTTP/1.1” 200 -
127.0.0.1 - - [28/May/2018 16:43:44] “GET /dummypath/_dash-layout HTTP/1.1” 404 -
127.0.0.1 - - [28/May/2018 16:43:44] “GET /dummypath/_dash-dependencies HTTP/1.1” 404 -

Any help is appreciated.

4 Likes

Hi Jack,

Did you find a solution to this problem. I have exactly the same issue, no idea how I get flask to look for /_dash-component-suites/ ? there is no such folder, confused. @chriddyp would you be able to help with this issue.

let me know
many thanks
Andreas

3 Likes

I also would love to have some feedback from this :slight_smile:

3 Likes

I also really need a solution for this.

1 Like

Hello, you can see my example for Flask_template_auth_with_Dash.

i saw your code. but still im confused with how you are integrating dash under with flask login_required page???
please help me im struggling with that part

just using flask_login.current_user.is_authenticated :slightly_smiling_face:
see Flask_template_auth_with_Dash/Dash_fun.py at master · jimmybow/Flask_template_auth_with_Dash · GitHub