Closed fordanic closed 4 years ago
Hmh, it appears that everything is all good when I serve the html file using a minimal flask application.
#!/usr/bin/python
# coding: utf-8
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def entry_point():
return render_template("index.html")
if __name__ == '__main__':
app.run(debug=True)
Ok, will have to rework the other application trying to figure out what happens there.
Why can't I use a specific route to serve the viewer?
#!/usr/bin/python
# coding: utf-8
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/OHIF/')
def entry_point():
return render_template("index.html")
if __name__ == '__main__':
app.run(debug=True)
@fordanic, you can serve it from a different base url, but you'll need to update the routerBaseName
key in the application config. You may also need to setup appropriate rules so SPA (single page application) routing works for direct linking to studies.
Note: you're using an older package of the viewer:
<script src="https://unpkg.com/@ohif/viewer@1.0.3/dist/index.umd.js" crossorigin></script>
The latest version is @ohif/viewer@3.3.4
Thanks for the hint regarding the routerBaseName, my mistake. Also handled the routing for SPA accordingly (in case someone tries something similar):
#!/usr/bin/python
# coding: utf-8
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def start():
return "Minimal OHIF + Flask example"
@app.route('/OHIF')
def study_list():
return render_template("index.html")
@app.route('/OHIF/viewer', defaults={'path': ''})
@app.route('/OHIF/viewer/<path:path>')
def study(path):
return render_template("index.html")
if __name__ == '__main__':
app.run(debug=True)
Thanks for the update, @fordanic! Lots of small things that are easy to get hung up on. Please don't hesitate to reach out if you have any further questions 👋
Trying to embed the viewer in a Flask application following the suggested approach. I.e. I have html file with following content:
And a route serving the specified html file. Everything loads properly upon visiting localhost:5000/viewer, no errors, but the page is completely blank. I assume, that I'm missing something basic somewhere, but I have no clue what it is.
Any suggestions are appreciated.