My assets is not working with dcc.Location:
Using dcc.Location as mentioned here: Multi-Page Apps and URL Support
I would like to assign my assets folder at run-time:
index.py
# Path managers
from pathlib import Path
CURRENT_PATH = Path(__file__)
CURRENT_DIR= CURRENT_PATH.parents[0]
from app import app
app.layout = html.Div([
dcc.Location(id='url', refresh=False),
html.Div(id='page-content')
])
@app.callback(Output('page-content', 'children'),
Input('url', 'pathname'))
def display_page(pathname):
if pathname == '/app':
app.title = "title"
app.assets_url_path= CURRENT_DIR.joinpath('app').joinpath('assets')
return app.layout
else:
return '404'
if __name__ == '__main__':
app.run_server(debug=True)
app.py
import dash
import dash_bootstrap_components as dbc
external_stylesheets = [dbc.themes.SIMPLEX, 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css']
app = dash.Dash( external_stylesheets=external_stylesheets
, suppress_callback_exceptions=True
, update_title='Loading...'
, serve_locally=True
)
server = app.server
tree
-prj/
| |-app.py
| |-index.py
| |-app/
| | |-app.py
| | |-assets/
| | | |-"*".css
Unfortunately this configuration is not working. Any ideas?
Thx!
Update:
Looks like it doesn’t work because it assets_folder is a read-only variable:
So, is it only possible to have one assets folder for all the apps which follows URL Routing and Multiple Apps | Dash for Python Documentation | Plotly ? Therefore no customization app by app?
Thx