#!/usr/bin/env python from CGIHTTPServer import test test()
def main(): test(CGIHTTPRequestHandler)
#!/usr/bin/env python from CGIHTTPServer import test;test()
def build_cgi_env(self, scriptname, *args, **kwargs): """ Adds SCRIPT_FILENAME to the env created by CGIHTTPRequestHandler CGIHTTPServer doesn't set the 'SCRIPT_FILENAME' environment variable, which causes php-cgi (on Ubuntu, at least) to fail with "No input file specified." Details: http://community.activestate.com/faq/cgi-debugging-no-input-fi """ env = CGIHTTPRequestHandler.build_cgi_env(self, scriptname, *args, **kwargs) env['SCRIPT_FILENAME'] = self.translate_path(scriptname) return env def parse_request_path(self): scriptname, scriptfile, script, rest, query = CGIHTTPRequestHandler.parse_request_path(self) php = Popen(["which", "php-cgi"], stdout=PIPE).communicate()[0].strip() return scriptname, php, scriptfile, rest, query def path_sanity_checks(self, *args, **kwargs): pass def output_script(self, php, scriptfile, query): """Execute a PHP script.""" CGIHTTPRequestHandler.output_script(self, php, 'php-cgi', scriptfile) if __name__ == '__main__': test(HandlerClass=PHPHandler)