Stopping a *HTTPServer
Sloth
mt_horeb at yahoo.com
Fri May 25 11:34:57 EDT 2001
Here's the situation - I'm building a quick-and-dirty application that
serves CGI and HTML via the CGIHTTPServer module. So far, so good.
The only issue that I am having is that I cannot figure out how to
stop the server once I've started it with serve_forever().
I've taken a look at some newsgroup posts and Web sites (incl.
http://www.python.org), but I cannot seem to locate an answer! I
would certainly appreciate anything that is more 'elegant' than simply
using Ctrl-C!
Here is the (very basic) code to create and start the server:
import CGIHTTPServer, BaseHTTPServer
class Handler(CGIHTTPServer.CGIHTTPRequestHandler):
cgi_directories = ["/cgi-bin"]
def startServer():
PORT = 8000
httpd = BaseHTTPServer.HTTPServer(("", PORT), Handler)
httpd.serve_forever()
Thanks!
Sloth
More information about the Python-list
mailing list