Forcing Python to detect DocumentRoot
barry at barrys-emacs.org
Sat Jan 19 12:40:35 CET 2013
On 16 Jan 2013, at 13:51, Ferrous Cranus <nikos.gr33k at gmail.com> wrote:
> When trying to open an html template within Python script i use a relative path to say go one folder back and open index.html
> f = open( '../' + page )
> How to say the same thing in an absolute way by forcing Python to detect DocumentRoot by itself?
In the general case it is not possible. There is no single convention you can use to detect the top of a web site.
If you always use apache httpd then read the value of DocumentRoot from httpd.conf
More information about the Python-list