I am running a simple Flask app and am having issues with file paths only when running the app on PythonAnywhere. I've tested the app locally on both Windows and macos and it seems to work fine in those environments. Here is the issue:
I have a file that I am trying to open inside a Python class file located here: /home/myuser/myflaskproj/someclass.py
The file I want to open is here: /home/myuser/myflaskproj/myfile.txt
I am trying to open the file using os.path.absfile
and I call it like this from within someclass.py: open(abspath('./myfile.txt'))
I am expecting this call to abspath to return this: /home/myuser/myflaskproj/myfile.txt
but instead it is returning this /home/myuser/myfile.txt
Why is it ignoring the myflaskproj
directory?
Thank you!