atyam anudeep
atyam anudeep

Reputation: 51

how to reload the flask server when I change my css code?

I am trying to edit my CSS code in the static folder. But the problem is: Flask is not reloading CSS changes.

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

I expected the changes but there is no change on editing the css file.

Upvotes: 4

Views: 5572

Answers (4)

Maen
Maen

Reputation: 815

You need to set reload template to true

app = Flask(__name__)
app.config["TEMPLATES_AUTO_RELOAD"] = True

Upvotes: 0

Amnon
Amnon

Reputation: 2320

You can use:

  • FLASK_RUN_EXTRA_FILES environment variable
  • --extra-files commandline arg
  • extra_files array arg to app.run()

see extra files docs

Upvotes: 1

Rodrigo E. Principe
Rodrigo E. Principe

Reputation: 1311

I had the same problem and it was the browser cache not clearing out. I found a solution for Chrome and Firefox: hold down the Shift key while clicking the reload button

Upvotes: 14

brillenheini
brillenheini

Reputation: 963

My guess is that static files are not checked for changes, even when Flask runs in debug mode. Additionally, CSS files are rather more browser related than to the application itself.

Regards, Thomas

Upvotes: 0

Related Questions