Reputation: 141
So my file directory looks like this:
/templates
--base.html
/static
--/css
----base.css
In the of my base.html file I have this line:
<link rel="stylesheet" href="{{ url_for('static', filename='css/base.css') }}">
However, when I run the app the base.css file isn't applied to the base.html page. In my browser I get the following error in the console:
GET http://0.0.0.0:8081/static/css/base.css net::ERR_ABORTED 404 (NOT FOUND)
I've already tried clearing my browser cache, hard refreshing the page, and restarting the app, but it still doesn't work.
Upvotes: 0
Views: 961
Reputation: 141
I've figured out the solution. I just needed to add the following to my __init__.py
file:
package_dir = os.path.dirname(
os.path.abspath(__file__)
)
static = os.path.join(
package_dir, "static"
)
app.static_folder=static
Upvotes: 3