fix: support static files on pyodide / py.cafe under a prefix #1486
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.
When a shiny app is running under a prefix (root_path in ASGI terms), the static files are not served correctly under pyodide. This is because the ASGI path includes the root_path, and the root_path should be removed.
Starlette 0.33 and 0.34 however, did not set root_path correctly, and in those cases, we have to rely on route_path.
Related discussions:
encode/starlette#2400
encode/starlette#2361
A related fix we had in Solara:
widgetti/solara#413
But this fix also did not seem to work for our situation at https://py.cafe
I logged the output of the relevant entries in the scope dict, together with the starlette version:
This was using a similar situation as on py.cafe:
Which led me to the following fix, making shiny work under pyodide in combination with a prefix with the above mentioned versions of starlette.