Simple Python Web Server with CGI

Here is the code for python CGI Web server :

 #!/usr/bin/env python  
 import BaseHTTPServer  
 import CGIHTTPServer  
 import cgitb; cgitb.enable() # This line enables CGI error reporting  
 ServerHandler = CGIHTTPServer.CGIHTTPRequestHandler  
 ServerHandler.cgi_directories = ["/"]  
 HttpServer = BaseHTTPServer.HTTPServer(("", 8000), ServerHandler)  

and here's the code for a sample page:

 #!/usr/bin/env python  
 print """Content-type:text/html\r\n\r\n  
  <title>Test Page</title>  
  <center><h1>Hello world. This is The Test Page</h1></center>  

then set the executable permissions for both file and run the

 $ chmod +x  
 $ chmod +x  
 $ ./  

now oen your web browser and type the following url


voila!!, thats it. For more information visit :