Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get URL parameters for bokeh application

Tags:

python

bokeh

Hi I am developing a bokeh application to perform some analysis. I want to get the URL parameters from the server so I can decide which data to render in the application.

Currently I can route URLs like http://127.0.0.1:5006/bokeh/videos/?hello=1 with the following configuration, but is there a way I can get the GET parameters {'hello':'1'} from the application?

@bokeh_app.route("/bokeh/analysis/")
@object_page("analysis")
def make_analysis():
    app = AnalysisApp.create()
    return app
like image 627
chtlp Avatar asked Aug 31 '15 17:08

chtlp


People also ask

How do I find parameters in URL?

For getting the URL parameters, there are 2 ways: By using the URLSearchParams Object. By using Separating and accessing each parameter pair.

What is ID parameter URL?

How Do You Identify a URL Parameter? To identify a parameter in a URL, you need to look for a question mark and an equals symbol within a URL. In this case, the “?” denotes the start of the parameter. The term “productid” is in of itself the parameter and in this case is designated as a product ID number.

How do I access my bokeh server?

host with the hostname or IP address of the gateway. You should now be able to access the Bokeh server from the local machine by navigating to localhost:5006 . You can even set up client connections from a Jupyter notebook running on the local machine.


2 Answers

Easier way: a dict of (param name, value) is available in curdoc().session_context.request.arguments.

For your URL http://127.0.0.1:5006/bokeh/videos/?hello=1, it would give {'hello', '1'}.

like image 111
Emmanuel Avatar answered Oct 18 '22 22:10

Emmanuel


For Flask (which Bokeh server is built on), you'd access url parameters using:

from flask import request

@bokeh_app.route("/bokeh/analysis/")
@object_page("analysis")
    def make_analysis():
    args = request.args
    app = AnalysisApp.create()
    return app

(the request object gets added to the function scope by the app.route decorator)

like image 39
Luke Canavan Avatar answered Oct 18 '22 20:10

Luke Canavan