def configure_static_route(app):
# Note (dmsimard)
# /static/ is provided from in-tree bundled files and libraries.
# /static/packaged/ is routed to serve packaged (i.e, XStatic) libraries.
#
# The reason why this isn't defined as a proper view by itself is due to
# a limitation in flask-frozen. Blueprint'd views methods are like so:
# "<view>.<method>. The URL generator of flask-frozen is a method decorator
# that expects the method name as the function and, obviously, you can't
# really have dots in functions.
# By having the route configured at the root of the application, there's no
# dots and we can decorate "serve_static_packaged" instead of, say,
# "static.serve_packaged".
@app.route('/static/packaged/<module>/<path:filename>')
def serve_static_packaged(module, filename):
xstatic = current_app.config['XSTATIC']
if module in xstatic:
return send_from_directory(xstatic[module], filename)
else:
abort(404)
评论列表
文章目录