Skip to content

Commit

Permalink
Merge pull request #93 from plotly/dash-wind-streaming
Browse files Browse the repository at this point in the history
Hotfix relative path assets (dash-wind-streaming)
  • Loading branch information
chriskfwoo authored May 17, 2019
2 parents 383e0cf + 9bbd54f commit 8f12b61
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,14 @@ Img(src="./assets/logo.png") will fail at root level

Tips

- Use [get_asset_url()](https://dash.plot.ly/dash-deployment-server/static-assets)
- Use [Pathlib](https://docs.python.org/3/library/pathlib.html) for more flexibility

```Python
import pathlib

# get relative assets folder
ASSETS_PATH = pathlib.Path(__file__, "/assets") # /assets
IMG_PATH = ASSETS_PATH.joinpath("logo.png") # /assets/logo.png
Img(src=str(IMG_PATH))
html.Img(src=app.get_asset_url('logo'))

# get relative data folder
DATA_PATH = pathlib.Path(__file__, "/data") # /data
Expand Down
12 changes: 8 additions & 4 deletions apps/dash-wind-streaming/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

server = app.server

BASE_ASSETS_PATH = pathlib.Path(__file__, "/assets").resolve()
LOGO_PATH = BASE_ASSETS_PATH.joinpath("dash-logo-stripe-inverted.png").resolve()

app_color = {"graph_bg": "#082255", "graph_line": "#007ACE"}

app.layout = html.Div(
Expand All @@ -35,7 +32,14 @@
),
]
),
html.Div([html.Img(src=str(LOGO_PATH), className="app__menu__img")]),
html.Div(
[
html.Img(
src=app.get_asset_url("dash-logo-stripe-inverted.png"),
className="app__menu__img",
)
]
),
],
className="app__header",
),
Expand Down

0 comments on commit 8f12b61

Please sign in to comment.