Woodz
Woodz

Reputation: 191

How can I add a simple png picture to my bokeh website?

I alread tried to add a picture by using a div container, but I always got a 404 error: "404 GET img/image.png (my-ip) 1.27ms".

What i'm doing wrong. Due to a similar issue on stackoverflow that method should work - I guess.

image_div = Div(text="<img src='img/image.png'>")

curdoc().add_root(image_div)


>> bokeh serve /dir/image.py --allow-websocket-origin=my-website:5006

Upvotes: 2

Views: 1042

Answers (1)

bigreddot
bigreddot

Reputation: 34588

A browser 100% cannot load local filesytem paths from a remote server. The images must be hosted and served by a real web server, ie. they must have actual http (or https) URLs in the img tag. You have three basic options:

  • Serve the images from some other remote web server
  • Run separate web server on this machine to serve the image files
  • Make the Bokeh app be a directory style Bokeh app which can serve files in a static subdirectory.

Which one is best for you depends heavily on the particulars of your situation.

Upvotes: 2

Related Questions