I have the following flask route that serves static content:
@app.route('/static/<path:path>')
@resourceDecorator
def getStaticFile(path):
return send_from_directory('static', path)
@resourceDecorator
declared as follows:
def resourceDecorator(f):
def new_func(*args, **kwargs):
resp = make_response(f(*args, **kwargs))
resp.cache_control.no_cache = True
resp.headers['Access-Control-Allow-Origin'] = '*'
return resp
return update_wrapper(new_func, f)
The decorator sets headers to deactivate caching and allows access to the cross domain. This works for my other, “regular” routes, but files sent via a static route do not seem to set their headers.
What is wrong here?
source
share