Panel with FastAPI

I’m trying to embed a simple Panel app with a template in FastAPI. When I browse to, the Panel template does not render for some reason. However it does render perfectly well when I browse directly to Can someone help me figure out what the issue is?

The code:

def createApp():
    x = [1, 2, 3, 4, 5]
    y = [6, 7, 2, 4, 5]
    p = figure(title="Simple line example", x_axis_label="x", y_axis_label="y")
    p.line(x, y, legend_label="Temp.", line_width=2)

    template = pn.template.FastListTemplate(title="My FastListTemplate")

app = FastAPI()
templates = Jinja2Templates(directory="templates")

async def bkapp_page(request: Request):
    script = server_document('')
    return templates.TemplateResponse("base.html", {"request": request, "script": script})

pn.serve({'/app': createApp},
        port=5000, allow_websocket_origin=[""],
        address="", show=False)
1 Like

Maybe try; not sure.