Accessing filepaths on the server

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

Read-only would be perfect actually. But it indeed seems they cannot be accessed. If anyone has a workaround, let me know :blush:

If you shared what you’re trying to accomplish, it would be easier to come up with Anvil ways to accomplish it.