How can I get the www folder path within a python script?

I’m using the following code

wwwPath = hass.config.path('www')

but I get the following error:
Error executing script: Not allowed to access HomeAssistant.config

Any hint?

Yes, you can’t use hass.config inside a python_script. It is a very limited sandbox.

What are you ultimately trying to do?

I want save a file in the www folder, but I’d like don’t hard-code absolute paths, so that It can work on different systems (hass.io, hassbian,…)

And how are you going to save the file? I suspect you can’t do file I/O. Are you using a service call to a standard HA component?

Sorry for the late reply, the file is written by an external python service started with the system startup (I’m using raspbian).

So now you have me totally confused. At first you seemed to imply the Python code was in a python_script – i.e., running inside HA. Now you say the script is running externally to HA. Which is it?

The python script, executed at startup, writes a file, and I want access it from a python_script.
Hope this clarify your doubts :slight_smile: