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
For getting the URL parameters, there are 2 ways: By using the URLSearchParams Object. By using Separating and accessing each parameter pair.
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.
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.
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'}
.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With