Karrigell Documentation

Version 2.3.3 15 01 07

Français

3. The Web server

The default built-in web server is asynchronous, like in the modules asyncore and asynchat in the standard Python distribution. As far as I could test it, it is very efficient, with very good response time (1)

3.1 The Root Directory

The Root Directory is the place where you place the files that will be reached on top of the url hierarchy ; if you place myfile.htm in this directory, it will be called by http://myhost/myfile.htm where myhost is your host name (try localhost)

On installation, the Root Directory is set to the subdirectory webapps of the Server Directory. You can change this in the configuration file (see configuration options)

3.2 Serving static files

To serve "static" files (HTML files, GIF or JPEG Images, etc) all you have to do is to create them using you favorite tool and save them to the Root Directory

Suppose you create an HTML document called myFile.htm and put it in the Root Directory. Launch your favorite Web Browser and type in the URL http://myhost/myFile.htm; you should see the file displayed in the browser

If you save the file in a subdirectory, you must prepend its name : for file myImage.gif in subdirectory Images, the url will be http://myhost/Images/myImage.gif

To reach files out of the Root Directory, use aliases (see configuration options)

If no file name is specified and the url matches a directory, the server looks for a file with the name index.html, index.htm, index.py, index.pih, index.hip or index.ks. If it doesn't find one, it prints a list of the subfolders and files in the directory; if it finds more than one, it raises an exception

If the extension of a file is not specified, the server will look for a file with one of the extensions html, htm, py, pih, hip or ks. If it finds one, this file is used ; if it finds more than one, an exception is raised ; if no file is found, an exception is raised too

3.3 Command line options


The command line is :

python Karrigell.py [-P port] [-S] [-D] [initFile]

where

  • port is the HTTP port number (default 80)
  • S specifies "silent" mode : by default, Karrigell prints a trace for each request it receives. With the -S option, nothing is printed
  • D sets debug level to 1 (see configuration options)
  • initFile is the configuration file (see below). Default is Karrigell.ini in the server directory

(1) you can also use an alternative built-in web server based on the modules SocketServer, BaseHTTPServer and SimpleHTTPServer module in the standard Python distribution : run python Karrigell_SocketServer.py

If you prefer a threaded server use python Karrigell_ThreadedSocketServer.py