Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with prefix #21

Closed
MarcSkovMadsen opened this issue Sep 23, 2024 · 0 comments · Fixed by #23
Closed

Does not work with prefix #21

MarcSkovMadsen opened this issue Sep 23, 2024 · 0 comments · Fixed by #23

Comments

@MarcSkovMadsen
Copy link
Contributor

MarcSkovMadsen commented Sep 23, 2024

I'm developing on a jupyterhub with code server, jupyter-server-proxy and jupyter-code-proxy installed installed.

This enables me to start up panel or fastapi in a jupyter or vscode terminal and via reverse proxying access the application.

Unfortunately this does not work with bokeh-fastapi as first reported in holoviz/panel#7277. A partial fix of this issue has been applied in holoviz/panel#7278, but @philippjfr mentioned that rest of fixes probably need to be in bokeh-fastapi.

The problem

In a Jupyterhub (or similar) environment

pip install fastapi[standard] panel bokeh-fastapi

Create the file main.py as described in Running Panel apps in FastAPI

import panel as pn

from fastapi import FastAPI, Request
from panel.io.fastapi import add_application

app = FastAPI()

@app.get("/")
async def read_root(request: Request):
    return {"Hello": "World", "root_path": request.scope.get("root_path")}

@add_application('/panel1', app=app, title='App 1')
def create_panel_app():
    slider = pn.widgets.IntSlider(name='Slider', start=0, end=10, value=3)
    return slider.rx() * '⭐'

@add_application('/panel2', app=app, title='App 2')
def create_panel_app():
    slider = pn.widgets.IntSlider(name='Slider', start=0, end=10, value=3)
    return slider.rx() * '❤️'

run the below in the "VS Code" terminal

fastapi dev main.py

Open the app at https://SOME-DOMAIN/SOME-PREFIX/vscode/proxy/8000/panel1

See issues

image

The problem is that it tries to find https://SOME-DOMAIN/static/extensions/panel/panel.min.js?v=1f4dc096d58f7d21e3875671aee6f29b120ab84218fa47db2cb53bc9eb5b4dac](https://mnr-jupyterhub.de-prod.dk/static/extensions/panel/panel.min.js?v=1f4dc096d58f7d21e3875671aee6f29b120ab84218fa47db2cb53bc9eb5b4dac

While it should be trying to find

https://SOME-DOMAIN/SOME-PREFIX/static/extensions/panel/panel.min.js?v=1f4dc096d58f7d21e3875671aee6f29b120ab84218fa47db2cb53bc9eb5b4dac](https://mnr-jupyterhub.de-prod.dk/static/extensions/panel/panel.min.js?v=1f4dc096d58f7d21e3875671aee6f29b120ab84218fa47db2cb53bc9eb5b4dac

Cause

I think the cause is the / prefix

image

Reproduce

I've tried to setup binder to reproduce in https://github.com/MarcSkovMadsen/panel-fastapi-experiments. You can open https://mybinder.org/v2/gh/MarcSkovMadsen/panel-fastapi-experiments.git/HEAD to reproduce.

Please note that depending on the binder server this might work or not work. I've experienced some binder servers catching the "proxy" endpoints and displaying their own web page instead.

bokeh-fastapi-issue.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant