I'm having an issue with/unsure how to use app$get_asset_url(). Could an example usage (in R) be shown?
Steps I tried to do:
- Initiate a Dash app with
library(dash); library(dashHtmlComponents); app <- Dash$new()
- Created an "assets" folder in the working directory and added a css file "test.css" to it with the contents
body { background: red; }
- Tried calling
app$get_asset_url("test.css") in the console, I got the following error message: "application not started via source(), and DASH_APP_PATH environment variable is undefined"
- Therefore, I defined that envvar to the current folder using
Sys.setenv("DASH_APP_PATH" = normalizePath(getwd())) and I tried running the same line. I still got the same error (this means the error is wrong - the envvar is now defined)
- I tried saving a "test.R" file with
library(dash); library(dashHtmlComponents); app <- Dash$new(); app$get_asset_url("test.css") and source-ing the file. Now I get an error "the asset path 'test.css' is not valid; please verify that this path exists within the 'assets' directory." (**this error also seems incorrect, as I do have that css file inside an assets directory)
@alexcjohnson mentioned that "get_asset_url is only really important when the app is being served with a path prefix."
It would be very helpful to see an example usage of this function.
I'm having an issue with/unsure how to use
app$get_asset_url(). Could an example usage (in R) be shown?Steps I tried to do:
library(dash); library(dashHtmlComponents); app <- Dash$new()body { background: red; }app$get_asset_url("test.css")in the console, I got the following error message: "application not started via source(), and DASH_APP_PATH environment variable is undefined"Sys.setenv("DASH_APP_PATH" = normalizePath(getwd()))and I tried running the same line. I still got the same error (this means the error is wrong - the envvar is now defined)library(dash); library(dashHtmlComponents); app <- Dash$new(); app$get_asset_url("test.css")and source-ing the file. Now I get an error "the asset path 'test.css' is not valid; please verify that this path exists within the 'assets' directory." (**this error also seems incorrect, as I do have that css file inside an assets directory)@alexcjohnson mentioned that "get_asset_url is only really important when the app is being served with a path prefix."
It would be very helpful to see an example usage of this function.