Pull session inside flask app with corresponding panel port
I have two questions:
Is it possible to parameterize the panel apps? (Say I have a bunch of datasets inside a db, and endpoints corresponding to the dataset /<int:id>/panel_app could I pull the data in automatically without using a “generic app” and choosing the dataset again?
I haven’t tried (yet) and maybe more a flask question but is there a way to start the panel app (maybe in a subprocess) when the endpoint is hit and kill it when left?
On a side note if it is useful for anyone I got dynamic holoviews working:
I also want to create a larger site of Panel apps for awesome-panel.org and for work. I’ve created a template you can use in practice or for inspiration.
Interesting I wasn’t aware of the syncing in locations could be useful! From what I understand though it only works with query parameters?
As for launching multiple apps I was somewhat aware of this but I thought the best UX in my case would be to have things carry over from routes or other rather than having separate applications, I am sure I could get it working with panel it just felt more “elegant” to do it with flask. It could just be though that I am not familiar enough with the panel ecosystem though
So I think I got something roughly working to how I want it using flask + panel.
It doesn’t dynamically load / serve a panel app.
Start the panel app (python -m panel serve sync.py --allow-websocket-origin=localhost:5000 where flask is running on port 5000
Inside my flask app I have
from bokeh.embed import server_document
from flask import render_template
@app.route('/<int:_id>/internal_oceans')
def internal_oceans(_id):
script = server_document(url='http://localhost:5006/sync',
arguments={'slider_value':67})
return render_template("app/internal_oceans.html", script=script)
The arguments are passed to the Bokeh Document which is accessible through panel.state.curdoc so stringing that all together we have access to arguments via panel.state.curdoc.session_context.request.arguments