Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dash plotly set custom folder as my assets folder

Tags:

plotly-dash

I've built a dash dashboard and customised the appearance using my own css. The structure of the app is below

Folder structure

I then dockerised and deployed the dashboard our linux servers. Unfortunately our linux servers have overwrriten the assets folder with it's own css.

In order the app to find it's own CSS, I need to specify my own assets folder in the dash app.

I've tried various syntax locally(below) but can't get it work

app = dash.Dash(__name__,static_folder='/new_assets/')
app = dash.Dash(__name__,assets_folder='/new_asssets/')
app = dash.Dash(__name__,assets_url_path='/new_asssets/')

Any advice on this would be greatly appreciated!

like image 863
Shahnur Islam Avatar asked Feb 14 '19 11:02

Shahnur Islam


1 Answers

Turn out this was the right way to do it, but you need to specify the absolute path so I added this line to the top of my code and running the code from the dashboard directory.

import os
assets_path = os.getcwd() +'/src/new_assets'
app = dash.Dash(__name__,assets_folder=assets_path)
like image 175
Shahnur Islam Avatar answered Oct 01 '22 02:10

Shahnur Islam