I am trying to launch my bokeh application on Microsoft IIS server via flask. Server administration and Windows are not my strong suits so it might be that I am missing something trivial.
The result is that one can access the page launched by flask but it doesn’t include my bokeh application. When I go to the localhost that contains my bokeh server it seem to work but I can not access that from outside the server computer itself.
I started with the example for embedding bokeh in flask: (I could not link properly due to being a new user but it is the one at examples/howto/server_embed/flask_embed.py)
and then followed the guide for launching flask on IIS: Deploying Python web app (Flask) in Windows Server (IIS) using FastCGI | by Bilal Bayasut | Medium
Any help would be really appreciated!
My code:
FlaskWrapper.py
from flask import Flask, render_template
from bokeh.embed import server_document
from tornado.ioloop import IOLoop
from threading import Thread
from bokeh.server.server import Server
import MainInterface
def modify_doc(doc):
MainInterface.modify_doc(doc)
app = Flask(__name__)
@app.route('/refengine/', methods=['GET'])
def bkapp_page():
script = server_document('http://localhost:5006/bkapp')
return render_template("embed.html", script=script, template="Flask")
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
server = Server({'/bkapp': modify_doc}, io_loop=IOLoop())
server.start()
server.io_loop.start()
Thread(target=bk_worker).start()
if __name__ == '__main__':
app.run()
embed.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Application</title>
</head>
<body>
<div>
This is text from embed.html
</div>
{{ script|safe }}
</body>
</html>
MainInterface.py
from bokeh.layouts import column
from bokeh.models.widgets import PreText
class MainInterface:
def __init__(self):
# There is more here but removed for simplicity
pass
def modify_doc(doc):
me.status_text = PreText(text="WELCOME", width=1600)
doc.add_root(column(me.status_text))
me = MainInterface()