Python + Windows + Webserver

Steve Pike spike at oztourer.nl
Mon Aug 13 03:55:50 EDT 2001


On Sun, 12 Aug 2001 11:30:41 GMT, gerson.kurz at t-online.de (Gerson
Kurz) wrote:

>On Sat, 11 Aug 2001 20:03:39 +0200, "Chris Eidhof" <chris at eidhof.com>
>wrote:
>
>>Hello, I'm looking for a *simple* way to set up a webserver under win98, the
>>webserver must handle python scripts. I've tried apache, but it didn't work.
>
>A *simple* webserver in python : 
>
>---- snip begin ----
>from SimpleHTTPServer import *
>test()
>---- snip end ----
>
>Its in your \python21\lib, hehe.

That should probably be CGIHTTPServer, unless you plan to list python
scripts rather than run them! Note that I was disappointed with the
Windows performance of my Python Wiki 'PikiePikie' compared to the
same script running under Linux (see
http://pikie.darktech.org/cgi/pikie?DevelopmentWebLog#SpeedyWindowsVersion
for details). It would seem that the import statement is much slower
under Windows and the threaded CGIHTTPServer will perform all imports
every time your script is run. The subclass shown below runs scripts
in-process so the imports only get performed once. It provides a two
second improvement for each page served up from my script on a 400 MHz
Windows box.

  import BaseHTTPServer
  import SimpleHTTPServer
  from CGIHTTPServer import CGIHTTPRequestHandler

  class InProcessHTTPRequestHandler(CGIHTTPRequestHandler):
      have_popen2 = 0

  def run(HandlerClass = InProcessHTTPRequestHandler,
             ServerClass = BaseHTTPServer.HTTPServer):
      SimpleHTTPServer.test(HandlerClass, ServerClass)

  if __name__ == '__main__':
      run()





More information about the Python-list mailing list