Forums

Flask app not updating, somehow using a cached version of the code

Hi, I'm getting an error related to an old version of a python file. The error is related to to file path that was stored in the old version of the file. If I look at the file on pythonanywhere's python editor, it shows the new version. The line that the error is referencing does not exist in the current file.

Things I've tried: - restarting the app (many times) - going into the file on pythonanywhere and re-saving it - clearing my browser cache, opening on 'incognito mode' or an alternate browser.

Is there a cache of the app I need to clear? Any help you could offer would be amazing. Thanks!

When people have hit problems like that in the past, normally what's happened is that they have somehow put two copies of their code on PythonAnywhere, and have been editing a different one to the one that is specified in the WSGI file. If you check out the WSGI file for your site, is it pointing at the directory you expect?

Hi, I am haviong the same problem Here.. What is weird, is it was updating the code before but I have not worked on it in a month or so. Now when I update the code, it is not updating on the browser, or live site. I will attach some of my code. Thanks

wsgi - https://ibb.co/nfRh3Tf this error in the wsgi - says "flask_app.app as application imported but never used" flask_app.py - https://ibb.co/m56WsGh error log- https://ibb.co/B4tCSLP

I am not sure if this is why my code is not updating but this is what I was able to find out so far. I was going to just redo my web app as it worked before, but I thought I might run into the same error.. Just weird it was working and as I have gone back, now it isnt..

Thanks!

The linter warning in the wsgi file ("flask_app.app as application imported but never used") is not something you should be concerned about (it's only saying that in this file object application is not used, but the linter doesn't know how the file will be run by uWSGI). The error log looks to show an older error, since @app.route in the flask_app.py has the missing parameter (maybe you should reload the web app)? Also, try using absolute path in the static_folder setting.

Yea, i have definitely reloaded. .. the absolute path goes to where? Maybe dumb question but not by my pc.

Thks

I was thinking about static_folder kwarg, where you instantiate the Flask app.

i deleted that webapp, relaunched it and changed the dns setup but it is still displaying the old code. it is quite bizaare.. its like it is an old cache but ive used different browsers from scratch anddeleted all cookies, etc.. Idk, I cannot figure it out

Are you sure that the web app is configured to use that new code? Is the old code still around?

I have updated the code. But it is just text.. logo. Etc.then i deleted the web app and configured the dns again. Howver, same settings. Idk. When i first started working on this thing. It was updating fine. Then i stopped working on it for a month and now it doesnt update.

Perhaps it would help if you could give us a specific example. I see that there is one website associated with your account, so I assume it's that one that's showing the problem. Could you:

  • Describe something on the site that shows the old behaviour suggesting that it's not been updated
  • Say where in the code the change that should have updated the behaviour is
  • Give us permission (just by saying so in a reply in this forum thread) to take a look at your code; we can see it from our admin interface but we need permission in order to do so.

/home/khundev/mysite/frontend/src/components/SiteNav.jsx > I changed the log and the login button text, .

/home/khundev/mysite/frontend/src/components/SiteNavLogin.jsx > changed login image

/home/khundev/mysite/frontend/src/components/home/TopList.jsx > here i changed the main header on the home page.. from Chok Dee Sentiment Bot > Chok Dee Sentiment Bot Updated,,

you guys have permission to look into the code.. thks

Those are JSX files that need to be compiled in order to be served. Your site only loads the compiled JS file main.e6c104c7.js, which doesn't appear to have been updated since October.

man, i knew it was something easy..haha, sorry for wasting your time on that.. and thanks for your time

No problem, glad we could help :)

I'm having the same problem but its saying this on the error log

2024-02-08 19:56:44,949: Error running WSGI application
2024-02-08 19:56:44,953: RuntimeError: does not exist: wordnerd.db
2024-02-08 19:56:44,953:   File "/var/www/wordnerd_pythonanywhere_com_wsgi.py", line 16, in <module>
2024-02-08 19:56:44,953:     from app import app as application  # noqa
2024-02-08 19:56:44,954: 
2024-02-08 19:56:44,954:   File "/home/wordnerd/mysite/app.py", line 2, in <module>
2024-02-08 19:56:44,954:     from helpers import parseCSV, getHint, login_required, encrPw, getPw
2024-02-08 19:56:44,954: 
2024-02-08 19:56:44,954:   File "/home/wordnerd/mysite/helpers.py", line 7, in <module>
2024-02-08 19:56:44,954:     db = SQL('sqlite:///wordnerd.db')
2024-02-08 19:56:44,954: 
2024-02-08 19:56:44,954:   File "/home/wordnerd/.local/lib/python3.10/site-packages/cs50/sql.py", line 67, in __init__
2024-02-08 19:56:44,955:     raise RuntimeError("does not exist: {}".format(matches.group(1)))
2024-02-08 19:56:44,955: ***************************************************
2024-02-08 19:56:44,955: If you're seeing an import error and don't know why,
2024-02-08 19:56:44,955: we have a dedicated help page to help you debug: 
2024-02-08 19:56:44,955: https://help.pythonanywhere.com/pages/DebuggingImportError/
2024-02-08 19:56:44,955: ***************************************************


db = SQL('sqlite:///wordnerd.db') <--- this one I've changed to 
db = SQL('sqlite:////home/wordnerd/mysite/wordnerd.db') <--- this because I read that pythonanywhere needs absolute path for the database file

but the change isn't even reflected on the console error I've pasted above. Its quite bizzare

Looks like the error.log show an error for db = SQL('sqlite:///wordnerd.db') -- did you reload the web app after changing the definition to contain the absolute path?