Web server Path Question

Erno Kuusela erno at iki.fi
Thu May 25 19:22:26 EDT 2000


>>>>> "vicl" == vicl  <vicl at my-deja.com> writes:

    vicl>   How do I specify the path of the file to write in a Python
    vicl> script running on a web server.

    vicl> Say the script is running in /usr/local/apache/cgi-bin (with
    vicl> alias /cgi-bin) and wants to write a file to
    vicl> /usr/local/apache/htdocs (with alias /)

    vicl> how do i specify the path in the script?

how about "/usr/local/apache/htdocs" ?-)

the filesystem namespace is not going anywhere so you
still specify the paths to files in the usual way.

when you are generating urls to send to the client,
then you better use the alias that maps your filesystem
namespace to the web.

however, it is best not to hardcode paths in your program.
cgi <URL:http://www.hoohoo.ncsa.uiuc.edu/cgi/>
specifies some environment variables that are useful.
in your case os.environ['DOCUMENT_ROOT'] would have the
value '/usr/local/apache/htdocs'.

  -- erno



More information about the Python-list mailing list