When launched, environment variables such as REQUEST_METHOD will be present as REQUEST_METHOD . If not, then you are not working in a CGI environment.
You can check it as follows:
import os if os.getenv("REQUEST_METHOD"): print("running as CGI") else: print("not running as CGI")
Greg hewgill
source share