Using "panel serve" renders blank page

Hi, I want to build a panel application consisting of various widgets and holoview plots. When i want to run this application using “panel serve” a blank page gets shown. If i however run the script directly via terminal using “python” everything is rendered just fine, but I do not have any access to panel.state.session_args which I need. This is the same behaviour both on windows and linux

Minimal examle:

def build_dashboard(args):
     # lots of widgets and 
     #calls to different modules to build up the dashboard, accumulated in
     return dashboard

if __name__ == "__main__":
    dashboard = build_dashboard(*args)

I’m using Panel v0.11.0a8. Any help regarding on how to run this properly or any pointers on where i might gone wrong are greatly appreaciated.

1 Like

Hi @Basti

Welcome to the community.

Try the below. It should work

import panel as pn

def build_dashboard():
     return pn.pane.Markdown("Hello World")

if __name__.startswith("bokeh"):
    # start with panel serve
    dashboard = build_dashboard()
if __name__ == "__main__":
    # start with python
    dashboard = build_dashboard()

Thanks for your quick resolution. I this works! I also tested it on my actual app! Thanks a lot.

1 Like