(Posted before to Stack Overflow without results)
I am currently developing a Bokeh dashboard to display pdfs. When starting the bokeh server from within the script itself, I have trouble accessing local files.
My directory structure looks as follows:
app/
├── static
│ └── test.pdf
└── test.py
Here, I would like to start the server from within test.py
(i.e. not via bokeh serve app
).
Minimum example of what I have tried so far: test.py
:
import os
import argparse
import bokeh.models
import bokeh.server.server
def app(doc):
text = '<embed src=\"static/test.pdf#page=6\"></embed>'
div = bokeh.models.Div(text=text)
doc.add_root(div)
if __name__ == '__main__':
port = xxxx
host_ip = xxx.xxx.xxx.xxx
origin = f'{host_ip}:{port}'
server = bokeh.server.server.Server(
{'/': app},
port=port,
address=host_ip,
allow_websocket_origin=[origin],
)
server.start()
server.io_loop.start()
I develop on a remote server to which I connect via ssh, hence the server settings.
However, when I run python test.py
from within the directory app
, I get the error message 404 GET /static/test.pdf
.
What is the path by which I can access the PDF? Is this even the correct approach?