Get URL parameters for bokeh application

一笑奈何 提交于 2019-12-22 05:59:46

问题


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

回答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)




回答2:


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'}.



来源:https://stackoverflow.com/questions/32316959/get-url-parameters-for-bokeh-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!