Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask doesn't seem to recognize file changes

Tags:

python

flask

A little background: I've been working on this project for about six months now and it's been running on Flask the whole time. Everything has been fine, multiple versions of the backend have been deployed live to support an app that's been in production for months now.

The development cycle involves writing everything locally and using Flask-Script's runserver command to test everything locally on localhost:8080 before deploying to a dev server and then finally to the live server.

The Problem: The other day my local flask instance, which runs on localhost:8080 apparently stopped respecting my local files.

I tried adding a new view (with a new template) and I got a 404 error when trying to view it in my browser.

I then tried making some test changes to one of the existing pages by adding a few extra words to the title. I restarted flask and none of those changes appeared.

I then went as far as deleting the entire views.py file. After restarting flask again, much to my dismay, I could still view the pages that were there originally (i.e. before this behavior started).

Finally, I made some changes to the manage.py file, which is where I put all of the Flask-Script commands, and they weren't recognized either. It's as if flask started reading from a cached version of the filesystem that won't update (which very well might be the case but I have no idea why it started doing this or how to fix the issue).

FYI: Browser caching shouldn't be an issue b/c I have the dev tools open with caching disabled. Plus the fact that changes to manage.py aren't being noticed shouldn't have anything to do with the browser.

like image 279
Analog24 Avatar asked Jul 24 '26 11:07

Analog24


1 Answers

You've most likely used flask in the DEBUG mode in which it auto reloads templates the app whenever a file changes.

Try using

export FLASK_DEBUG=True

before running

flask run

For more information see http://flask.pocoo.org/docs/1.0/config/#DEBUG

like image 50
JohnGalt Avatar answered Jul 26 '26 00:07

JohnGalt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!