What I’m trying to do:
On the server, is there a working alternative for BASE_DIR = Path(__file__).parent
?
I’m getting the following error: NameError: name '__file__' is not defined
What I’ve tried and what’s not working:
Tried using os
module: same error.
As I understand it, your running server-side code does not have access to the source-code directories (and even if it did, those should be read-only).
However, they do have access to a data directory, and to “asset” files. See
Working With Files, Media And Binary Data Anvil has built-in support for uploading, storing, downloading, and manipulating files and other binary data.
There are 3 ways to work with files in Anvil:
Dynamic Files, Media and Binary data Dynamic Files,...
Read-only would be perfect actually. But it indeed seems they cannot be accessed. If anyone has a workaround, let me know
If you shared what you’re trying to accomplish, it would be easier to come up with Anvil ways to accomplish it.