Access HTTP Request State#
This guide addresses how to access information about the HTTP request associated with a session.
See the How to > Access and Manipulate the URL guide to learn how to work with the URL.
panel.state object holds a wide range of information about the HTTP request that is associated with a running session. Note that if you are running Panel inside a notebook session these attributes will simply return
The request arguments are made available to be accessed on
pn.state.session_args. For example if your application is hosted at
?phase=0.5 to the URL will allow you to access the phase variable using the following code:
phase = int(pn.state.session_args.get('phase'))
phase = 1
This mechanism may be used to modify the behavior of an app depending on parameters provided in the URL.
panel.state.headers will allow accessing the HTTP headers stored in the browser and on the bokeh server.