#133 Fix an issue of background image does not show up when server base URL path is specified #134
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Close #133
Summary
Fix an issue of the background image does not show up when Streamlit server base URL path is specified (via
config.toml
file,--server.baseUrlPath
when running, or environment variableSTREAMLIT_SERVER_BASE_URL_PATH
).Version: 0.9.3
Description
The
background_image_url
obtained fromst_image.image_to_url
has the format:/media/xxxxxx.png
.If we specify the
server.baseUrlPath
like, for example,foo
:And when the URL is constructed at the frontend side with the origin:
A single slash
"/"
is missing between the origin and the base path, so the image can not be loaded.This PR handles the
server.baseUrlPath
a little bit before appending it to the head of the image URL returned fromst_image.image_to_url
. I strip all the extra leading and trailing slashes if there are any and then add a single one to the beginning so that the frontend side can construct the correct path.How Has This Been Tested?
I've tested locally in Docker environment and the original example
app.py
inREADME.md
:Dockerfile:
You can also try different strange values for
server.baseUrlPath
like///foo/bar//
, etc.