I've managed to get CORS running with:
from flask.ext.cors import cross_origin
@app.route("/cors/<path:file>")
@cross_origin(file)
def corsFolder(file):
return send_from_directory("/home/noiv/XYXYX", file, mimetype="application/octet-stream")
However, I don't want everyone and his cat fetch these files for free. So, how do I restrict access to certain referring domains? There are at least three including localhost:port.
Regarding static/dynamic, I have no choice as these images get rendered on a HTML5 canvas made available as blob to users and static leads to a 'tainted' canvas which doesn't allow any export at all.
BTW: the flask/cors thing adds a nice cache/max age header, which at least in my case leads to less bandwidth and even better response, because files are loaded locally the from browser's cache without any round trip
Many thanks on any input!
--noiv