How to do the best practice with FastAPI

Hi, I’ve been following the Panel tutorial for FastAPI.

I found that the embedded HTML contains the Panel/Bokeh server info which I do not intend to expose.

Code (main.py)

Exactly the same code as the tutorial (providing / and /app2 to show panels):

# Following the Panel tutorial for Multiple apps
@app.get("/")
async def bkapp_page(request: Request):
    script = server_document('http://127.0.0.1:5000/app')
    return templates.TemplateResponse("base.html", {"request": request, "script": script})

@app.get("/app2")
async def bkapp_page2(request: Request):
    script = server_document('http://127.0.0.1:5000/app2')
    return templates.TemplateResponse("app2.html", {"request": request, "script": script})

Visit FastAPI server (127.0.0.1:8000)

I open 127.0.0.1:8000 (FastAPI server) in my browser, and the HTML shows the bokeh server in the JS script (which is 127.0.0.1:8000):

and so does 127.0.0.1:8000/app2:

Here is a image you need to imagine, because I encounter "Sorry, new users can only put one embedded media item in a post", and it does not allow a new member to post with images.

https://discuss.python.org/t/discourse-message-sorry-new-users-can-only-put-one-embedded-media-item-in-a-post/8037/1

Visit Bokeh server (127.0.0.1:5000)

Now I tried to visit 127.0.0.1:5000, and it shows the Panel homepage which I did not intend to expose:

Here is a image you need to imagine, because I encounter "Sorry, new users can only put one embedded media item in a post", and it does not allow a new member to post with images.

https://discuss.python.org/t/discourse-message-sorry-new-users-can-only-put-one-embedded-media-item-in-a-post/8037/1

I try to go App page (127.0.0.1:5000/app) and it shows nothing:

Here is a image you need to imagine, because I encounter "Sorry, new users can only put one embedded media item in a post", and it does not allow a new member to post with images.

https://discuss.python.org/t/discourse-message-sorry-new-users-can-only-put-one-embedded-media-item-in-a-post/8037/1

Issues

  1. This approach will expose the Panel/Bokeh server in the HTML (what I do not intend to do).
  2. The Panel server (127.0.0.1:5000) can be visited and it shows the list (what I do not intend to do).
  3. Visiting the dashboard (e.g. 127.0.0.1:5000/app) within the unintended Panel homepage, it shows nothing.

Is there any way to hide the Panel Server for users? Could I just run Panel without Bokeh server?

If you put in allowed_origin parameter only the fastapi address the panel site should refuse all other connections.