0

I am learning how to build flask applications. But, whenever I write some CSS code, and link that to my html template, the css never gets applied. No matter what I do.

Here is the line that links my html template to my css file:

<link rel="stylesheet" href="{{ url_for('static',filename='css/base.css') }}">

Here is what I did:

  1. I tried restarting my server.
  2. I searched for this online. This is what I found: CSS not being applied in Flask app. However, even that did not help.

I believe my server does not find my css file, because this is the entire output in my terminal:

* Serving Flask app "app" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 222-949-106
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [11/Nov/2020 21:18:46] "GET /login HTTP/1.1" 200 -
127.0.0.1 - - [11/Nov/2020 21:18:47] "GET /login HTTP/1.1" 200 -

As you can see, my css file is not mentioned anywhere. Where is the mistake? Please help me.

Samyak Jain
  • 347
  • 1
  • 4
  • 17

1 Answers1

1

I hope this is because of the cache. The browser will load CSS once from the server and then it will be stored in the cache memory.

You do remove the cache memory by Shift + F5.

Note: If you may think that the server does not find your CSS file, but if it can't able to find the file, you may encounter with 404 error. In your case, you didn't get that error. So the only possible answer is CACHE.

NavaneethaKrishnan
  • 1,213
  • 1
  • 9
  • 22