Question

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 ?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top