Read and modify a bokeh slider value from flask

Hello,
I am exploring the communication between a Flask server and a Bokeh server.

from flask import Flask, render_template

from bokeh.embed import components
from bokeh.plotting import figure

from bokeh.client import pull_session
from bokeh.embed import server_session

app = Flask(__name__, template_folder="/home/luigi/my-bokeh/sliders/templates")

session = pull_session(url="http://192.168.1.101:5006/sliders")

# generate a script to load the customized session                                                                                                                                                 
script = server_session(session_id=session.id, url='http://192.168.1.101:5006/sliders')

@app.route('/get', methods=['GET'])
def get():

    value = session.document.get_model_by_name("amplitude").value

    return str(value), 200

@app.route('/set', methods=['GET'])
def set():
                                                                                                                                                                            
    session.document.get_model_by_name("amplitude").value = 0.9                                                                                                                                                                               

    value = session.document.get_model_by_name("amplitude").value

    return str(value), 200

I have a main problem at the moment. When I change the value of the slider with

session.document.get_model_by_name("amplitude").value = 0.9
# session.push()

the bokeh slider is not updated.
In order to obtain an update, I need uncomment


above. However, if I do that, than the plot does not react anymore to the change of the slider,
until I reload the plot.

Another problem is the following: if I set the value of the slider with “set”, then I can read properly with “get”, howver the value I read is the one I have set, and not the one of the slider.

I appear that the session.document is not updated nor shared between flask and the bokeh server

Any idea? Thanks!