Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should I put `favicon.ico` so bokeh serve can find and render it?

Tags:

bokeh

I have a directory format app, named myapp like:

myapp/
   |
   + -- main.py
   + -- favicon.ico
   + -- static
           |
           + -- some.img

If I run bokeh serve myapp, I keeps getting 404 GET /favicon.ico (::1).

Where should I put favicon.ico?

like image 698
gepcel Avatar asked Dec 01 '17 04:12

gepcel


2 Answers

You can add an HTML template to a Bokeh application, under the templates directory. With that, you can specify an favicon location in the normal way in the <head> of your template. For an example of an app that uses a template, see the crossfilter demo in the GitHub repo.

The template just needs to have

{{ plot_div }}
{{ plot_script }}

in the <body>. The app is rendered wherever the plot_div is located.

like image 148
bigreddot Avatar answered Oct 19 '22 17:10

bigreddot


Create folder "templates" and add "index.html" with

{% extends base %}

{% block preamble %}
<link rel="icon" type="image/x-icon" href="myapp/static/favicon.ico">
{% endblock %}

And move your "favicon.ico" in the folder "static". So you have:

myapp/
   |
   + -- main.py
   + -- templates
           |
           + -- index.html
   + -- static
           |
           + -- favicon.ico

Here are some more information about extending the bokeh template. https://docs.bokeh.org/en/latest/docs/user_guide/embed.html#standard-template

Also kudos to the answer from bigreddot and the helpful comment by gepcel.

like image 4
CodePrinz Avatar answered Oct 19 '22 17:10

CodePrinz