cgi dectection

Jeff Bauer jbauer at rubic.com
Thu Jul 27 12:01:11 EDT 2000


Michael Lunnay wrote:
> is there a standard way to detect if script is being 
> run as a cgi script or from the command line. 


I usually build test cgi scripts by checking for the
SERVER_PROTOCOL environment variable, e.g.:

  if os.environ.has_key('SERVER_PROTOCOL'):
      run()
  else:
      test()


Hope that helps.

Jeff Bauer
Rubicon Research




More information about the Python-list mailing list