Hello Community!
I was trying several ways to serve multiple applications and I found the following as one of the ways:
import panel as pn
pn.extension(sizing_mode="stretch_width")
pages = {
"Page 1": pn.Column("# Page 1", "...bla bla bla"),
"Page 2": pn.Column("# Page 2", "...more bla"),
}
def show(page):
return pages[page]
starting_page = pn.state.session_args.get("page", [b"Page 1"])[0].decode()
page = pn.widgets.RadioButtonGroup(
value=starting_page,
options=list(pages.keys()),
name="Page",
sizing_mode="fixed",
button_type="success",
)
ishow = pn.bind(show, page=page)
pn.state.location.sync(page, {"value": "page"})
ACCENT_COLOR = "#0072B5"
DEFAULT_PARAMS = {
"site": "Panel Multi Page App",
"accent_base_color": ACCENT_COLOR,
"header_background": ACCENT_COLOR,
}
pn.template.FastListTemplate(
title="As Single Page App",
sidebar=[page],
main=[ishow],
**DEFAULT_PARAMS,
).servable()
However, when I run this code on my device, this error pops up:
pn.state.location.sync(page, {"value": "page"})
AttributeError: 'NoneType' object has no attribute 'sync'
Can anyone help how to resolve this?
Thanks!