Hi,
Below is the structure of my project, [dd-> refers to dropdown], The bold ones are directories, except init.py
|-advertiser-conversion-board
|- assets
|-favicon.ico
|-font.css
|-font-awesome-min.css
|- icon-blue.jpg
|-jquery-3.2.1.min.js
|-normalize.min.css
|-skeleton.min.css
|- components
|-init.py
|-custom.css
|-functions.py [Contains all the functions to connect to the dB & and get values to fill the 1st dd, and based on the selected value of 1st dd, 2nd dd get populated]
|- header.py [Ignore]
|-table.py. [Ignore]
|-init.py
|-app.py
|-callbacks.py [contains the callback to fill the 2nd dd, based on the selected value of 1st dd]
|-layouts.py [contains the layouts for 1st and 2nd dropdown]
The issue, the app works completely in a single app format, so there is no issue with code or imports hence i am sharing app.py file which i believe have some issue that i am unable to figure it out.
In app.py, I have not defined any separate pathnames or link other than ‘/’, and want the whole layout in ‘/’.
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
from layouts import layout_base
import callbacks
from flask import send_from_directory
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets, url_base_pathname='/')
app.css.config.serve_locally = True
app.scripts.config.serve_locally = True
app.config.suppress_callback_exceptions = True
app.index_string = '''
<!DOCTYPE html>
<html>
<head>
{%metas%}
<h1>Advertiser Conversion Dashboard</h1>
{%favicon%}
{%css%}
</head>
<body>
{%app_entry%}
<footer>
<div>Advertiser Conversion Dashboard</div>
{%config%}
{%scripts%}
{%renderer%}
</footer>
</html>
'''
app.layout = html.Div([
html.Link(href='/assets/skeleton.min.css', rel='stylesheet'),
html.Link(href='/assets/font-awesome-min.css', rel='stylesheet'),
html.Link(href='/assets/normalize.min.css', rel='stylesheet'),
html.Link(href='/assets/font.css', rel='stylesheet'),
html.Link(href='/assets/jquery-3.2.1.min.js', rel='script'),
dcc.Location(id='url', refresh=False),
html.Div(id='page-content')
])
# Update page
# # # # # # # # #
@app.callback(Output('page-content', 'children'),
[Input('url', 'pathname')])
def display_page(pathname):
if pathname == '/':
return layout_base
else:
return '404'
@app.server.route('/assets/<path:path>')
def static_file(path):
static_folder = os.path.join(os.getcwd(), 'assets')
return send_from_directory(static_folder, path)
# Run the App Server
if __name__ == '__main__':
app.run_server(debug=True, port=9002)
Can you help when i am getting wrong ?