Exemple #1
0
#!/usr/bin/env python

from CGIHTTPServer import test
test()
#!/usr/bin/env python

from CGIHTTPServer import test

test()
Exemple #3
0
def main():
    test(CGIHTTPRequestHandler)
Exemple #4
0
#!/usr/bin/env python

from CGIHTTPServer import test;test()
Exemple #5
0
	
	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)