I am using Pythonanywhere to host a simple Flask web app for an academic project. The tutorial set me up with a simple flask_app.py hello world file that showed up at the url provided. I then deleted that example file and used the bash console to import files from my project group's github repo, expecting the app to now work off of my own files rather than the hello world file. However, whenever I try to run it, I get a "Something went wrong" error
Apologies if a similar question has been answered before, I was unable to find it in a cursory search.
I assume that the issue here is that the server is expecting to read the exact hello world file that I deleted, and is confused because I replaced it incorrectly. I have tried reloading the app using the reload button, changing the app's source code directory, working directory, and WSGI config file to point at the directory containing my new backend.py file, I have tried putting the contents of my files back into the original "mysite" folder. Still, I cannot seem to get the web app to work as it did with that hello world file. I know I must be missing something stupid. Do I perhaps need to specify the name of the python file I want the url to be connected to? If so, where? Am I missing something basic in my python file?
Below is some info that may be helpful. The Error log shows that some file cant find a module, however I have no idea what file is throwing this error, how to fix it, or what I did to cause this. Thanks for your help.
Screenshot of config file locations, I have reset them to the default.
The contents of that "mysite" folder that the hello world was originally in.
Error Log for the day of troubleshooting:
2023-02-10 16:40:46,043: If you're seeing an import error and don't know why,
2023-02-10 16:40:46,043: we have a dedicated help page to help you debug:
2023-02-10 16:40:46,044: https://help.pythonanywhere.com/pages/DebuggingImportError/
2023-02-10 16:40:46,044: ***************************************************
2023-02-10 16:40:48,418: Error running WSGI application
2023-02-10 16:40:48,418: ModuleNotFoundError: No module named 'flask_app'
2023-02-10 16:40:48,418: File "/var/www/stagesetupapp_pythonanywhere_com_wsgi.py", line 16, in <module>
2023-02-10 16:40:48,418: from flask_app import app as application # noqa
2023-02-10 16:40:48,419: ***************************************************
2023-02-10 16:40:48,419: If you're seeing an import error and don't know why,
2023-02-10 16:40:48,419: we have a dedicated help page to help you debug:
2023-02-10 16:40:48,419: https://help.pythonanywhere.com/pages/DebuggingImportError/
2023-02-10 16:40:48,419: ***************************************************
2023-02-13 16:14:17,492: Error running WSGI application
2023-02-13 16:14:17,495: ModuleNotFoundError: No module named 'flask_app'
2023-02-13 16:14:17,495: File "/var/www/stagesetupapp_pythonanywhere_com_wsgi.py", line 16, in <module>
2023-02-13 16:14:17,496: from flask_app import app as application # noqa
2023-02-13 16:14:17,496: ***************************************************
2023-02-13 16:14:17,496: If you're seeing an import error and don't know why,
2023-02-13 16:14:17,496: we have a dedicated help page to help you debug:
2023-02-13 16:14:17,496: https://help.pythonanywhere.com/pages/DebuggingImportError/
2023-02-13 16:14:17,496: ***************************************************
When you deploy a web app on PythonAnywhere it automatically creates a wsgi file (as currently web apps on PA have to be WSGI compatible) -- this file is accessible via the Web page of your web app. You have to update the file providing correct paths to your project and the application
object (I guess in your case that would be from backend import app as application
, assuming that path is available). For debugging tips you can always fall back to the page that is linked in the error log (which you copied above): https://help.pythonanywhere.com/pages/DebuggingImportError/.