0

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.

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.