
Hello,
We’re building an image viewer/browser with Bokeh server. Currently, when a user selects one or more points in a scatter plot, using a Python callback:
-
the corresponding images are loaded into NumPy arrays from the file paths
-
then these are displayed in a separate canvas using image_rgb
This turns out to not be super-performant, and I thought it’s probably wasteful to decompress on the server. I don’t know what Bokeh is doing in the background but I imagine either re-compressing to transfer to the browser, or transferring the uncompressed data. Either of these approaches is pretty wasteful, so I presume that image_url would be faster. I’ve read the previous post on the topic [1] where Bryan posted some very specific advice about how to structure the app directory:
make a “directory” style app
make a “static” subdirectoy in the app directory
put all your pngs, etc in the “static” subdirectoy
then anything in the static directory is available at the relative
URL “myappname/static” (substitute whatever your actual app name is for
“myappname”)
And, further dashing my hopes and dreams:
Just to be clear, it’s never going to be possible to load files from
arbitrary filesystem locations like “C:/foo/bar.png”, only from the application-specific “static” directory.
Now, please correct my logic if I’m wrong, but I presume that there is an asterisk to the above statement: Bokeh must somehow be serving up that directory, and it should be possible to make it serve some other arbitrary directory (tree), rather than one specifically named “static” in a specific part of the filesystem. So I have two questions:
-
How is Bokeh serving up the static directory? Can you point me to the right part of the Bokeh codebase? We are calling the Bokeh server manually [2], so we need to figure this out anyway, even if serving from static/.
-
Alternatively, is there a more effective way to send the jpg from the server to the “Image” object, rather than decompressing on the server?
Thanks,
Juan.


