Application not picking up .css file (flask/python) [duplicate]

You need to have a ‘static’ folder setup (for css/js files) unless you specifically override it during Flask initialization. I am assuming you did not override it.

Your directory structure for css should be like:

/app
    - app_runner.py
    /services
        - app.py 
    /templates
        - mainpage.html
    /static
        /styles
            - mainpage.css

Notice that your /styles directory should be under /static

Then, do this

<link rel= "stylesheet" type= "text/css" href= "https://stackoverflow.com/questions/22259847/{{ url_for("static',filename="styles/mainpage.css") }}">

Flask will now look for the css file under static/styles/mainpage.css

Leave a Comment

tech