holoviz / panel

Panel: The powerful data exploration & web app framework for Python
https://panel.holoviz.org
BSD 3-Clause "New" or "Revised" License
4.61k stars 500 forks source link

FastAPI tutorial does not work with templates #6658

Open pmeier opened 5 months ago

pmeier commented 5 months ago

ALL software version info

panel==1.4.0
bokeh==3.4.0
hvplot==0.9.2
numpy==1.26.4
pandas==2.2.1
fastapi==0.110.1
jinja2==3.1.3
uvicorn==0.29.0

OS: Arch Linux Browser: Firefox and Chromium

Description of expected behavior and the observed behavior

I want to run a panel app behind a FastAPI server. When following the simple example in official panel tutorial, everything works out well. However, if one goes a little further and tries to run an app based on a panel template, the tutorial breaks down.

Complete, minimal, self-contained example code that reproduces the issue

Here is a repo with everything necessary to reproduce. TL;DR I've combined the FastAPI example with the example in the documentation of the pn.templates.FastListTemplate.

Screenshots or screencasts of the bug in action

panel serve app.py viewed under http://localhost:5006/app

panel_serve

uvicorn main:app viewed under http://127.0.0.1:8000/

uvicorn

pmeier commented 5 months ago

cc @t-houssian as OP of #2870, who added the original tutorial.