简体   繁体   中英

Python CGI Open file with absolute URL path

I'm writing a Python script that opens a file based on the URL (using .htaccess). I want to be able to open it using an absolute path relative to the servers DocumentRoot. With PHP I would do:

$_SERVER['DOCUMENT_ROOT']/path

Is there a similar function with CGI?

Thanks.

I finally found the solution, just use:

import os
os.environ['CONTEXT_DOCUMENT_ROOT']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM