在Bokeh服务器应用程序中获取JSON请求



我想将用户引导到散布服务器托管的页面以及一些元数据。例如,我可能想将用户引导到

http://my-server/my-page?var=value

然后,我想在python侧的散布服务器应用程序代码中获取{'var': 'value'}请求,以便我可以做出相应的响应。

这可能吗?如果是这样,如何?

一个散型核心Dev将我指向此文档页面:

https://docs.bokeh.org/en/latest/docs/user_guide/server.html#accessing-the-the-http-request

尤其是在文档对象上可用的:

# request.arguments is a dict that maps argument names to lists of strings,
# e.g, the query string ?N=10 will result in {'N': [b'10']}
args = curdoc().session_context.request.arguments
try:
  N = int(args.get('N')[0])
except:
  N = 200

最新更新