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

Nested path not working. #24

Closed
MarcSkovMadsen opened this issue Sep 23, 2024 · 3 comments · Fixed by holoviz/panel#7318
Closed

Nested path not working. #24

MarcSkovMadsen opened this issue Sep 23, 2024 · 3 comments · Fixed by holoviz/panel#7318

Comments

@MarcSkovMadsen
Copy link
Contributor

MarcSkovMadsen commented Sep 23, 2024

This is not urgent for me. But it would be super nice finally to get nested paths like /apps/panel supported with Panel enabling much nicer organisation of paths. Not being able to nest paths is quite surprising for newcomers to Panel in my experience.

import panel as pn

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

pn.extension("tabulator")

app = FastAPI()

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

@add_application('/apps/panel', app=app, title='Sub Panel')
def create_panel_app():
    slider = pn.widgets.IntSlider(name='Slider', start=0, end=10, value=3)
    return slider.rx() * '😊'
fastapi dev main.py

open http://127.0.0.1:8000/apps/panel

Watch the blank screen.

Check the server 404 error in the terminal

$ fastapi dev main.py
INFO     Using path main.py
INFO     Resolved absolute path C:\repos\awesome-panel\main.py
INFO     Searching for package file structure from directories with __init__.py files
INFO     Importing from C:\repos\awesome-panel

 ╭─ Python module file ─╮
 │                      │
 │  🐍 main.py          │
 │                      │
 ╰──────────────────────╯

INFO     Importing module main
INFO     Found importable FastAPI app

 ╭─ Importable FastAPI app ─╮
 │                          │
 │  from main import app    │
 │                          │
 ╰──────────────────────────╯

INFO     Using import string main:app

 ╭────────── FastAPI CLI - Development mode ───────────╮
 │                                                     │
 │  Serving at: http://127.0.0.1:8000                  │
 │                                                     │
 │  API docs: http://127.0.0.1:8000/docs               │
 │                                                     │
 │  Running in development mode, for production use:   │
 │                                                     │
 │  fastapi run                                        │
 │                                                     │
 ╰─────────────────────────────────────────────────────╯

INFO:     Will watch for changes in these directories: ['C:\\repos\\awesome-panel']
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [26728] using WatchFiles
INFO:     Started server process [40088]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     127.0.0.1:53589 - "GET / HTTP/1.1" 200 OK
INFO:     127.0.0.1:53617 - "GET /apps/panel HTTP/1.1" 200 OK
INFO:     127.0.0.1:53617 - "GET /apps/static/extensions/panel/bundled/datatabulator/tabulator-tables%406.2.1/dist/css/tabulator_simple.min.css?v=1.5.0 HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:53617 - "GET /apps/static/extensions/panel/bundled/reactiveesm/es-module-shims%40%5E1.10.0/dist/es-module-shims.min.js HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:53618 - "GET /apps/static/extensions/panel/bundled/datatabulator/tabulator-tables%406.2.1/dist/js/tabulator.min.js HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:53619 - "GET /apps/static/extensions/panel/bundled/datatabulator/luxon/build/global/luxon.min.js HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:53617 - "GET /apps/static/js/bokeh-widgets.min.js?v=a9b89524d45c9917073e9a3e35c284447f993ef108f68d4609e2b4618a4a2310af427b818b53f467ff1ece8714c2f0e8ad8f3e76361f410e292253bd271199d8 HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:53618 - "GET /apps/static/js/bokeh-tables.min.js?v=fbbe15922c8405a08cc90e24b24fb8e2339900a06a31f2dc8263235cd50ea70b731c2b09f7e07d7e7460065bdb7c32d0b9a1301c9b302846688b542b8db17f6d HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:53622 - "GET /apps/static/js/bokeh-gl.min.js?v=db4741fb9fd48f2bbc9938de834e307697a72bddfc4e8930c5056d0236b7261716d55c585e04a8373ed9e95da60ea8b37e93a215bc7ed5108744e649e972914f HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:53621 - "GET /apps/static/js/bokeh.min.js?v=65047a94adfa94bbcbed48f015c6d04e50b19dc96ee98f9f1da3a528dd90e59cf692724ded03c9f955605b6c0f029d7460cfcade979e2633a6387c7682b0cc16 HTTP/1.1" 404 Not Found
INFO:     127.0.0.1:53620 - "GET /static/extensions/panel/panel.min.js?v=1f4dc096d58f7d21e3875671aee6f29b120ab84218fa47db2cb53bc9eb5b4dac HTTP/1.1" 200 OK

Check the errors in the browser console

image

@MarcSkovMadsen
Copy link
Contributor Author

Would probably also Make it much easier to enable a full Panel based website like dash, Solara or reflex websites https://x.com/getreflex/status/1838361670361751694?s=46&t=QCeLnYcdhHHHwawHQ7y8xA.

@philippjfr
Copy link
Collaborator

Should be fixed in holoviz/panel#7318

@philippjfr
Copy link
Collaborator

Next I would like to support path parameters.

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.

2 participants