How do you use url_for
in Flask to reference a file in a folder? For example, I have some static files in the static
folder, some of which may be in subfolders such as static/bootstrap
.
When I try to serve a file from static/bootstrap
, I get an error.
<link rel=stylesheet type=text/css href="{{ url_for('static/bootstrap', filename='bootstrap.min.css') }}">
I can reference files that aren't in subfolders with this, which works.
<link rel=stylesheet type=text/css href="{{ url_for('static', filename='bootstrap.min.css') }}">
What is the correct way to reference static files with url_for
? How do I use url_for
to generate urls to static files at any level?