By William
Disclaimer & Background: I am a hobbyist programmer trying to learn how to set up a webserver to host replayable text-logs from a game I play. Every thing I know about coding is self taught via Google/Stack Overflow. I am trying to understand the relationship between deployed nginx+uwsgi+flask so I can continue to solve & maintain what I have written so far.
Problem: In short, how do I ensure that changes to .py files that are successfully viewed over the internet served via the virtualenv as well as a cli-run uwsgi can also be successfully viewed over the internet via the defined ip and domain.
Detail: I have successfully followed @jtittle1’s step-by-step solve to a basic nginx+uwsgi+flask set up. The basic site sits here.
This works in virtualenv, cli-run uwsgi, by ip and domain.
When I updated my second page (modifying a placeholder), I can successfully view my changes when running the virtualenv as well as the cli-run uwsgi. However, despite restarting the daemonized services and nginx, I am still viewing my placeholder when I navigate to the specified ip and domain.
I have run into an iteration of this problem before where I had to remove (and allow rebuild of) existing .pyc files. I am not sure this is the problem here as I have removed my existing .pyc files and still view the placeholder page. I have viewed this across multiple naive browsers so it is not a cached response.
My question is: if all of my application is represented by the .py files I have since modified, what on earth am I viewing? Abstractly, nginx is serving me a version of my application that is no longer apparently available to me in my application directory. Where and what is this?
Thanks for your patience!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello,
Your Flask application’s state might be getting cached in a few places, which could be preventing your updates from being reflected. Here are a few areas to check:
sudo service uwsgi stop
sudo ps aux | grep uwsgi # Confirm that no uwsgi processes are running
sudo service uwsgi start
sudo service nginx restart
Browser Cache: As you’ve already suspected, it’s also possible that your browser has cached an old version of your site. Try accessing your site in an incognito/private browsing window, or clear your browser’s cache.
Flask Application: Ensure that there are no .pyc or pycache files left in your Flask application’s directory. These are compiled Python bytecode files that could be out of date. You can remove these with:
find /path/to/your/app -name '__pycache__' -delete
find /path/to/your/app -name '*.pyc' -delete
If none of the above steps help, you might have a problem with your Flask application’s code or its interaction with uWSGI or NGINX. It would be helpful to check the logs of each service to look for any errors or warnings.
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.