We have written our custom rule in our function that handles URL mapping for our application. We wrote something like app.add_url_rule('rule/for/custom/paths'). Whenever we try to access the contents of static folder, it hits the custom rule that we wrote.

Apart from using Sub Domains for this purpose, do we have any other alternative to access the static files ?

有帮助吗?

解决方案

Your custom rule and the value of the static_url_path parameter overlap. Rename one or the other.

You can easily use a different URL path for the static resources, for example:

 app = Flask(__name__, static_url_path='/assets')

would set the URL path for static resources to /assets; as long as you are using url_for('static', filename='path/to/static/asset') in your Flask code and templates, that's all you need to do to avoid clashing.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top