prof-rossetti / intro-to-python

An Introduction to Programming in Python
Other
97 stars 244 forks source link

Flask displaying old / cached version of the app #114

Open s2t2 opened 1 year ago

s2t2 commented 1 year ago

A handful of students are encountering an issue whereby they are developing a flask app locally, and when they make some new changes to the code and restart the local web server, it doesn't show the updated changes, but rather what appears to be an older state of the web app code.

I have confirmed they are saving the files properly and restarting the web app, and their code looks identical to mine and other students whose apps are working locally. The weird thing is the same code and usage command works for me and many other students, but not for a few of them.

See https://github.com/pallets/flask/issues/4874

Hopefully we can hear about a fix to this issue.

s2t2 commented 1 year ago

Before troubleshooting, make sure there isn't a local flask server running, or stop it with control+c.

Troubleshooting

We can open up the Powershell program on Windows, which is an alternative version of Git Bash, and run the following commands...

First we see what processes are currently running on port 5000:

netstat -ano | findstr :5000

If there are issues, you may see multiple entries get returned, meaning there are some old processes we need to kill.

image

We can run the following command from powershell to kill a given process, specifying the number provided by the netstat command results:

# where 18956 is an example process number found from the previous command
stop-process 18956

Repeat this command for all process numbers.

After all the old processes are cleared, the next time you run flask run it should reflect the current state of your app! 🎉

Unfortunately in the future you may need to continue to repeat this process. But at least it helps us get unblocked.