Cannot set panel app as index (with --index option)

I tried to set my own panel app as the index for a set of panel apps (since I cannot change the default index template). I start the apps like this:

panel serve ../src/dashboard/apps/*  --index myindex

myindex is one of the apps served
Being a bit more explicit by enumerating all apps individually does not work either:

panel serve ../src/dashboard/apps/acties ../src/dashboard/apps/activiteiten_en_verrichtingen ../src/dashboard/apps/demo ../src/dashboard/apps/myindex --index myindex

The myindex app works fine in itself.

All attempts yielded this error:

2021-12-27 17:48:15,041 Uncaught exception GET / (::1)
HTTPServerRequest(protocol='http', host='localhost:5006', method='GET', uri='/', version='HTTP/1.1', remote_ip='::1')
Traceback (most recent call last):
  File "/Users/mjm/Dropbox/Devel/ACHN/Dashboard/.venv/lib/python3.10/site-packages/tornado/web.py", line 1704, in _execute
    result = await result
  File "/Users/mjm/Dropbox/Devel/ACHN/Dashboard/.venv/lib/python3.10/site-packages/panel/io/server.py", line 275, in get
    await super().get(*args, **kwargs)
  File "/Users/mjm/Dropbox/Devel/ACHN/Dashboard/.venv/lib/python3.10/site-packages/bokeh/server/views/root_handler.py", line 66, in get
    self.render(index, prefix=prefix, items=sorted(self.applications.keys()))
  File "/Users/mjm/Dropbox/Devel/ACHN/Dashboard/.venv/lib/python3.10/site-packages/tornado/web.py", line 862, in render
    raise RuntimeError("Cannot render() after finish()")
RuntimeError: Cannot render() after finish()

Any ideas on how to set index app?

PS panel recognises the index app, otherwise one would get the error message:

ERROR: The --index argument must either specify a jinja2 template with a .html file extension or select one of the applications being served as the default. The specified application 'myindexxxx' could not be found.

I have since found out that one can set a jinja templated index.html. Be sure to provide the absolute path to the file. So:

panel serve --autoreload ../src/dashboard/apps/* --index /..../Dashboard/run/index.html

Then I used these contents for the index file, effectively redirecting to the panel app that I want to use as an index app (start_here in my case):

<html>
<head>
    <meta http-equiv="Refresh" content="0; url='/start_here'" />
</head>
<body>
redirecting...
</body>
</html>

Ugly, but it works.

2 Likes