I have been using following approach:
# Custom static data
@app.route('/cdn/<path:filename>')
def custom_static(filename):
return send_from_directory(app.config['CUSTOM_STATIC_PATH'], filename)
The CUSTOM_STATIC_PATH
variable is defined in my configuration.
And in templates:
{{ url_for('custom_static', filename="foo") }}
Caveat emptor – I’m not really sure whether it’s secure 😉