How to display static images in Bokeh using Div

In my project based on the Bokeh server, I have to use / add several images located in the Bokeh project folder. I created a static folder called "static /" in the project folder, and basically my code looks like this:

  div_img_html = "<img src='static/image.png'>"
  div_img = Div(text = div_img_html)

however, when the server starts, I get:

  404 GET /static/image.png (::1) 2.00ms

Obviously, Bokeh receives the Div command, but the server does not know how to get the actual file .... The actual file, of course, is in this folder.

Thank you in advance for any suggestions and hopefully for a solution!

+4
source share
1 answer

, . static ( --prefix). . myapp:

bokeh serve --show myapp

static/image.png,

from bokeh.models import Div
from bokeh.io import curdoc

div = Div(text="<img src='myapp/static/foo.png'>")

curdoc().add_root(div)

, - , . GitHub.

+2

Source: https://habr.com/ru/post/1666361/


All Articles