Python Server Plus

First, you need a box. Assuming you have a box, with Python in it, but no web server, here is a server for you:


    #!/usr/bin/python
    # make sure the path points at your interpeter
    from SocketServer import ThreadingMixIn
    import BaseHTTPServer, CGIHTTPServer, os
    #
    os.chdir ('../web')
    #
    class ThreadingCGIServer(ThreadingMixIn,BaseHTTPServer.HTTPServer):
pass
    import sys
    server=ThreadingCGIServer(('',8080),CGIHTTPServer.CGIHTTPRequestHandler)
    try:
        while 1:
            sys.stdout.flush()
            server.handle_request()
    except KeyboardInterrupt:
        print 'Finished.'

YES, that is a complete threading server with cgi support. Should be able to handle more than a thousand connections. This version works in windows OR un*x. Thank you, SteveHolden.


ok, stick that in the server in the web cgi-bin. DO NOT START IT YET.

Assuming your box does not yet mount a webserver, you need to give it a simple tree structure of directories. I like a simple tree if I can get away with it:

    /www+ <-- web pages
        +/images <- image files
        +/cgi-bin+ <- all scripts.
                 +/texts <- wiki pages

Now you want a wiki. There are several fine python wiki's. Wikinehesa is easy to install. Download the tarball and stick it in the web server.

Put plain old html pages in /www, image files in /www/imagesscripts and their .cf files in /www/cgi-bin, and any pages for the wiki in /www/cgi-bin/texts. You might like to hack up an index.html for it to look at.

Edit the .cf file, replacing the example values with your preferences. They are red in sequence, and comment lines after them explain them some. Make sure everything is owned by nobody, and the scripts are permissioned 755, and the pages are 644. You do not need to edit the scripts

Then fire it up.

#ns./threadingserver.py

You have a server, and a wiki. Visit the index.html page and see that it is working, then click a link you thoughtfully placed there to visit your wiki. When you click on a link to the wiki script, it will default to FrontPage. If there is none, it will create it containing only the invitation to contribute to the page.

-- KirkBailey


CategoryPython


EditText of this page (last edited June 16, 2006) or FindPage with title or text search