newbie to python and linux here. I dont understand how the OS module in python can access system specific functions for example the getcwd() method which returns the current directory of the system, in linux this would be equivalent of typing in "pwd" into a terminal right? Does this python module and its methods open a terminal in the background and return information from it?
(i have a flask server and want to browse directories and files on a raspberry pi through a website with jquery/ajax, in order to do this i thought i would use the OS module with the getcwd() method and listdir(). Right now when the flask server starts, it runs a python code which calls the getcwd() method and returns the string to the html page with ajax jquery. When i opened a new terminal on the pi and changed the directory, it did not update the directory which the python code returns to the html webpage. This lead me to question where and how python executes these commands and whether it is done in an invisible terminal). Looking back i think this makes sense, because when you open 2 terminals on linux you could be in different directories in each terminal without them affecting eachother. So is the python code run in the same terminal where the flask process is running? because it doesnt show up there.
Ive tried google and looked through this: https://hg.python.org/cpython/file/3.2/Lib/os.py but havent found any answers yet...