Flask / Django Server and Bokeh Server

I want to implement a dynamic web control panel with Python 3.x (Like Shiny for R)

Bokeh seems promising from what I read and saw on YouTube.

What is not clear when and where do I need a Bokeh server and Flask / Django Server? Will they complement each other? Or can I work on one? Will they both serve the same thing?

+5
source share
1 answer

The Bokeh server is based on Tornado, which in itself is a powerful Python web framework and an asynchronous network library. Depending on your needs, you can simply write a Bokeh app to show everything you want, the way you want. Bokeh provides the ability to customize the look of the app using Jinja2 templates. You can see an example of this in the Gapminder demo at http://demo.bokeh.org .

However, you may have more complex needs, especially with regard to authentication and access, or you may have an existing site that you need to integrate into. In this case, you are probably considering embedding the Bokeh application on another page that can be submitted from Flask, Django, IIS, or any other. There are two main ways to do this:

  • using server_document to generate a <script> which you can template on your page, which will embed the application from the Bokeh server on the page
  • using <iframe> to embed a URL from a Bokeh server into a page

Any of them can work just fine. Depending on the complexity of the deployment environment, there may be more things like "devops-y" to use the Bokeh server behind a proxy server or with a load balancer, etc. In the " Starting Bokeh Server " section of the User Guide, there is much more information for those who want to dive into these details.

If you embed the application from the Bokeh server to another web page, the Bokeh server must be operational to serve the application! How to do this is a separate task; there are several ways to do this:

  • run as an external process and manage something like supervisord . You can see a full deployment example like this at https://github.com/bokeh/demo.bokeh.org

  • embed the Bokeh server "in" your Flask / Django / application anything by running your own IOLoop . You can see one example of this technique in examples/howto/server_embed . In addition, this should probably be considered a fabulous expanded use.

+7
source

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


All Articles