I’m trying to create a bokeh webapp with authentication (Azure AD) and deploy to Azure Web Services. I figure that flask would provide authentication and pass traffic back and forth from bokeh. This All has to happen through a single port unless I customize a docker image for azure.
I’ve been banging my head against this for 2 days (novice web programmer here) but I can’t get flask to send all traffic to bokeh. The closest I got was the code below.
As you can see, I’ve made it to the point that all traffic is passed off to bokeh EXCEPT websocket traffic. This means I hit another roadblock since a simple flask proxy using Response() wont work with websockets (I think).
Any suggestions on what I can try? At this point I think my requirements are too stringent for just flask + bokeh and I might have to do nginx + bokeh using this:
I would have thought this was a popular use case, but for some reason, I can’t find many examples. Thanks!
···
…
@app.route(’/’)
def bkapp_page():
script = server_document('http://localhost:5000/bkapp')
return render_template("embed.html", script=script, template="Flask")
bokeh_server_baseurl = ‘http://localhost:5006/’
@app.route(’/test’, defaults={‘path’: ‘’})
@app.route("/test/path:path")
def bkapp(path):
url = bokeh_server_baseurl + 'test/' + path
print(url)
req = requests.get(url)
resp = Response(stream_with_context(req.iter_content()), content_type=req.headers['content-type'])
return resp
def bk_worker():
# Can't pass num_procs > 1 in this configuration. If you need to run multiple
# processes, see e.g. flask_gunicorn_embed.py
print("in")
server = Server({'/bkapp2': modify_doc}, prefix='test', io_loop=IOLoop(), allow_websocket_origin=["*"])
server.start()
server.io_loop.start()
…
``