Thanks. I have bokeh server and django running simultaneously now:
bokeh serve --allow-websocket-origin=localhost:8000 test_app/test_calc
(There is a bokeh app contained in main.py in test_app/test_calc)
Django is running on 192.168.56.10:8000 and my pre-existing routes are working.
I have a url route for ^bokeh_test/ mapping to a view:
class BokehTestDash(TemplateView):
template_name = ‘bokeh_test.html’
def get_context_data(self, *args, **kwargs):
from test_app.test_calc import main # was getting an error ‘parent module not imported’ without this line
context = super(BokehTestDash, self).get_context_data(**kwargs)
context[‘script’] = autoload_server(url=‘http://localhost:5006’)
And my bokeh_test.html file has simply:
{% extends ‘base.html’ %}
{% block content %}
{{ block.super }}
Bokeh Test
{{ script|safe }}
{% endblock content %}
When I navigate to 192.168.56.10:8000 or 192.168.56.10:8000/bokeh_test, the page loads with the “Bokeh Test” header, but nothing else loads. In the log I can see a deprecation warning that I know is coming from my bokeh app at main.py, but nothing is resolving on the page.
Any guidance out there would be greatly appreciated!
Cheers,
Dan
···
On Thursday, August 10, 2017 at 9:26:16 AM UTC-7, [email protected] wrote:
Hi Dan,
I manually start my Bokeh and Django servers separately. Scripting it sounds like a good idea, but I haven’t looked into it… I’m also not even remotely an expert, so don’t take my word.
You shouldn’t need a new bokeh server per request. One Bokeh server can handle that for you. Basically, my Django server just provides a gate to my Bokeh server. I only allow my bokeh server to be accessed by Django traffic. However, this isn’t entirely secure. I should really be implementing additional security measures.
I manually start one Bokeh server (per Bokeh app) and one Django server.
Hope that helps… or prompts a smarter person to help you
Dan
On Thursday, August 10, 2017 at 10:48:30 AM UTC-5, Dan Kovacek wrote:
Hi Dan and Angelo,
I’m currently working on something similar, thanks to both for posting your examples. Dan, did you do as Angelo and run a shell script separately to run bokeh server alongside Django? I saw the examples in the docs to launch the server with tornado and ioloop, but for me it seemed like to implement in Django I would incorporate the code after `if name == ‘main’ in manage.py.
Right now for development, I’m running python manage.py runserver 0.0.0.0:8000 to get django running, then in a separate window I run bokeh serve … as Angelo did. I’m not very familiar with running shell scripts, is it common in production to run the two shell scripts as daemon processes? If done this way, is the number of servers equal to the number of arguments, independent of the number of requests? Is it normal to not have a new bokeh server for each request (or user/visitor)? Please feel free to set me straight if I’m mixing up terminology.
Thanks!
Dan
On Thursday, May 11, 2017 at 5:07:38 PM UTC-7, Angelo Fausti Neto wrote:
Hi Dan,
glad you solved your problem. I have to update to 0.12.5.
Another thing that might be of interest if you are embedding bokeh apps in django is how to pass url parameters from one bokeh app to another.
You have to do that through django so that you can embed the second app.
My solution for that was to set a cookie in the HTTP Response of the first bokeh app with the full django url
https://github.com/lsst-sqre/qa-dashboard/blob/master/squash/dashboard/views.py#L206
then the second bokeh app can recover the url parameters from the bokeh server HTTP Request and set its state.
Example:
https://github.com/lsst-sqre/qa-dashboard/blob/master/squash/dashboard/viz/api_helper.py#L185
and
https://github.com/lsst-sqre/qa-dashboard/blob/master/squash/dashboard/viz/AMx/main.py#L22
wondering if there’s a better solution for that.
best,
Angelo Fausti Neto
LIneA/LSST
On Thu, May 11, 2017 at 4:54 PM, [email protected] wrote:
By the way, I would be happy to share my Django code as that is as simple as it can be (because I just learned everything I know about Django last night)… although I’ve already provided nearly all of it. The Bokeh code I’m using, however, is not ideal for an example. But from what I can tell, if you have a Bokeh app server running with default parameters, the views.py and html code is all you need in addition to setting up a very basic Django (or similar) web server.
On Thursday, May 11, 2017 at 6:31:05 PM UTC-5, [email protected] wrote:
Hi Angelo,
Thank you of responding and pointing to some examples. Placing {{script|safe}} inside
Old:
DVH Datbase Django Testing
{{ script }}
``
New (and working):
DVH Datbase Django Testing
{{script|safe}}
``
In response to the 0.12.5 differences:
All autoload_server parameters are optional and app_path is deprecated.
http://bokeh.pydata.org/en/latest/docs/reference/embed.html#bokeh.embed.autoload_server
Defining the url and app_path keywords produces this warning:
/Library/Python/2.7/site-packages/bokeh/util/deprecation.py:34: BokehDeprecationWarning: app_path was deprecated in Bokeh 0.12.5 and will be removed, use url instead. Now pass entire app URLS in the url arguments, e.g. ‘url=http://foo.com:5010/bar/myapp’
On Thursday, May 11, 2017 at 5:45:00 PM UTC-5, Angelo Fausti Neto wrote:
Hi Dan,
it looks like you are missing some arguments in the bokeh autoload_server()
Here is my solution to embed a bokeh app in django templates, this is using bokeh 0.12.4 though - I know that autoload_server() has changed in 0.12.5 but I haven’t had time to update yet.
urls.py
https://github.com/lsst-sqre/qa-dashboard/blob/master/squash/dashboard/urls.py#L27
views.py
https://github.com/lsst-sqre/qa-dashboard/blob/master/squash/dashboard/views.py#L186
embed_bokeh.html template
https://github.com/lsst-sqre/qa-dashboard/blob/master/squash/dashboard/templates/dashboard/embed_bokeh.html#L25
hopefully this example helps.
PS.: at some point I would like to provide a minimum code example for this integration, let me know if you (or somebody) is interested.
best,
Angelo Fausti Neto
LIneA/LSST
On Thu, May 11, 2017 at 1:18 PM, [email protected] wrote:
Hi all,
This is possibly a trivial question, but I’m new to Bokeh and I have essentially no experience with html or javascript.
I have a standalone Bokeh server running at localhost:5006 and works perfectly fine when accessed directly. But I’d like to implement user logins via django. I’ve been able to set up a django server, but I am missing something. I do not see any Bokeh server activity when accessing the the django app (not even a websocket rejection), so I’m leaning towards html syntax being the issue? An (unauthorized) example i found had instead of what i posted below, but that didn’t work either.
I’ve also tried hard-coding an autoload_server() return into the template, but that did not work either.
Any advice is greatly appreciated. Thanks!!
dvh_viewer.html
DVH WebApp
DVH Datbase Django Testing
{{ script }}
views.py
def dvh_viewer(request):
script = autoload_server()
t = TemplateResponse(request, 'dvh/dvh_viewer.html', {"script": script})
t.render()
return t
What I see when accessing the django url (localhost:8000)
DVH Datbase Django Testing
Bokeh 0.12.5
Python 2.7
Mac OS Sierra and Ubuntu 16.04
–
You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/7fa18453-3f1f-45b4-b2b7-ee648918f566%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
–
You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/aebb46f0-b826-4387-a9fb-30d10dbbdcd2%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.