cgihttprequesthandler

CGIHTTPRequestHandler run php or python script in python

柔情痞子 提交于 2019-12-21 05:46:32
问题 I'm writing a simple python web-server on windows.. it works but now I want to run dynamic scripts (php or py) and not only html pages.. here is my code: from BaseHTTPServer import HTTPServer from CGIHTTPServer import CGIHTTPRequestHandler class RequestsHandler(CGIHTTPRequestHandler): cgi_directories = ["/www"] #to run all scripts in '/www' folder def do_GET(self): try: f = open(curdir + sep + '/www' + self.path) self.send_response(200) self.send_header('Content-type', 'text/html') self.end

Python CGIHTTPServer Default Directories

筅森魡賤 提交于 2019-12-04 03:57:18
问题 I've got the following minimal code for a CGI-handling HTTP server, derived from several examples on the inner-tubes: #!/usr/bin/env python import BaseHTTPServer import CGIHTTPServer import cgitb; cgitb.enable() # Error reporting server = BaseHTTPServer.HTTPServer handler = CGIHTTPServer.CGIHTTPRequestHandler server_address = ("", 8000) handler.cgi_directories = [""] httpd = server(server_address, handler) httpd.serve_forever() Yet, when I execute the script and try to run a test script in

CGIHTTPRequestHandler run php or python script in python

天涯浪子 提交于 2019-12-03 20:45:42
I'm writing a simple python web-server on windows.. it works but now I want to run dynamic scripts (php or py) and not only html pages.. here is my code: from BaseHTTPServer import HTTPServer from CGIHTTPServer import CGIHTTPRequestHandler class RequestsHandler(CGIHTTPRequestHandler): cgi_directories = ["/www"] #to run all scripts in '/www' folder def do_GET(self): try: f = open(curdir + sep + '/www' + self.path) self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() self.wfile.write(f.read()) f.close() except IOError: self.send_error(404, "Page '%s' not found