I want my RPi to open run a python webserver and open Chromium to access it.
It should do it automaticaly on startup.
BUT
When I run the script via command
$ sudo python3 /home/sps-training/python/webserver.py
and open localhost on chromium, it says that it can't access HTML file in another folder (/deploy)
but when I open the dictionary first
$ cd /home/sps-training/python/
and then open the script
$ python3 webserver.py
it suddenly works!
So there are 2 possible solutions
The first one is to make it work by using:
$ sudo python3 /home/sps-training/python/webserver.py
The second one is to automatically access directory and the start the script
Right now I'm using /etc/profile to run it on startup (I just wrote at the last line with & on the end of the line)
Thanks a bunch for every advice!
btw sorry for grammar
Like Barmar said. It sounds like the issue you're running into is a working directory vs. current directory problem. When you run sudo python3 /home/sps-training/python/webserver.py  you are launching webserver.py in the directory / and if it looks for "deploy/index.html" it's going to look in /deploy/index.html. However, when you cd into /home/sps-training/python/ and then run python3 webserver.py the working directory is now /home/sps-training/python/ and it will look for deploy/index.html in /home/sps-training/python/deploy/index.html
The best solution is to edit the python script to use absolute file paths.
Barring that, you need to cd to the correct working directory every time.
RPi - accessing a folder and then running a python script on startup