Python script to generate static site?

has has.temp2 at
Thu Aug 12 14:16:04 CEST 2004

Fred <fred at> wrote in message news:<hl5lh0pb3u4m47f2bsatc9vigrv7pc7v07 at>...

> I'd just like a script that would 
> 1. look in a directory for articles in raw HTML,
> 2. generate a cooked output for each page (ie. add header and footer,
> CSS link in HEAD, etc.),
> 3. regenerate the homepage with "Last modified" bit following each
> article's title,
> 4. ready to be uploaded by FTP to a web server that only handles
> static web pages.

This should be close to what you want:
<>. (See

To add 'last modified' dates, replace the second-last line of with:

import time
index = '<ol>\n%s</ol>' % ''.join(['\t<li><a href="%s">%s</a>
%s</li>\n' % (href, name, time.strftime('(last modified: %I:%M:%S %p
on %Y-%m-%d)', time.localtime(os.stat(src + href).st_mtime))) for
name, href in chapterNames])

More information about the Python-list mailing list