@@ -150,10 +150,12 @@ class Dash(object):
150
150
:type assets_ignore: string
151
151
152
152
:param assets_external_path: an absolute URL from which to load assets.
153
- Use with ``serve_locally=False``. Dash can still find js and css to
154
- automatically load if you also keep local copies in your assets
155
- folder that Dash can index, but external serving can improve
156
- performance and reduce load on the Dash server.
153
+ Use with ``serve_locally=False``. assets_external_path is joined
154
+ with assets_url_path to determine the absolute url to the
155
+ asset folder. Dash can still find js and css to automatically load
156
+ if you also keep local copies in your assets folder that Dash can index,
157
+ but external serving can improve performance and reduce load on
158
+ the Dash server.
157
159
env: ``DASH_ASSETS_EXTERNAL_PATH``
158
160
:type assets_external_path: string
159
161
@@ -1098,9 +1100,7 @@ def _setup_server(self):
1098
1100
def _add_assets_resource (self , url_path , file_path ):
1099
1101
res = {"asset_path" : url_path , "filepath" : file_path }
1100
1102
if self .config .assets_external_path :
1101
- res ["external_url" ] = "{}{}" .format (
1102
- self .config .assets_external_path , url_path
1103
- )
1103
+ res ["external_url" ] = self .get_asset_url (url_path .lstrip ("/" ))
1104
1104
self ._assets_files .append (file_path )
1105
1105
return res
1106
1106
@@ -1185,11 +1185,12 @@ def csp_hashes(self, hash_algorithm="sha256"):
1185
1185
]
1186
1186
1187
1187
def get_asset_url (self , path ):
1188
- asset = get_asset_path (
1189
- self .config .requests_pathname_prefix ,
1190
- path ,
1191
- self .config .assets_url_path .lstrip ("/" ),
1192
- )
1188
+ if self .config .assets_external_path :
1189
+ prefix = self .config .assets_external_path
1190
+ else :
1191
+ prefix = self .config .requests_pathname_prefix
1192
+
1193
+ asset = get_asset_path (prefix , path , self .config .assets_url_path .lstrip ("/" ))
1193
1194
1194
1195
return asset
1195
1196
0 commit comments