1.13 web.util -- Useful utility functions that don't fit elsewhere

This module provides a number of functions which come in handy when programming web applications but that don't fit in elsewhere. It is a catch all module for useful leftovers.

wrap( text, width)
A word-wrap function that preserves existing line breaks and most spaces in the text. Expects that existing line breaks are posix newlines. (ie backslash n)
text
The text to wrap
width
The maximum number of characters in a line

strip( html, [validTags=[]])
Strip illegal HTML tags from string
html
The HTML which needs some tags stripping
validTags
A list or tuple of tags to leave in place

runWebServer( [root='../', cgi='/cgi-bin', ])
Run a simple webserver on port 8080 on localhost. The root of the website corresponds to the directory root. cgi is URL of the the cgi-bin where files can be executed. Once this command is run code execution stops as the webserver listens for requests so there is no point in writing code after this command as it will not be run.

Warning: NOT SUITABLE FOR COMMERCIAL USE.

dir
The only directory where scripts are allowed to run. Directory names should be the full URL path from the root of the webserver and therefore should begin with /



Subsections