Script API v 0.2.3

Cleaning & Rendering

It’s easy to include Pageit in your own scripts:

from pageit.render import Pageit
Pageit(path='.').clean().run()

Watching for File Changes

Use watch() to call a callback function when files change:

from pageit.tools import watch
def my_func(path):
    print path, 'has changed'

with watch(path='.', callback=my_func) as watcher:
    watcher.loop()  # wait for CTRL+C

See also

watchdog for the cross-platform directory-watching library

Basic HTTP Server

Use serve() to serve up files on a given port:

from pageit.tools import serve
serve(path='.', port=80)  # will wait until CTRL+C

See also

Python’s built-in SimpleHTTPServer for serving directories

Watching & Serving

If you want to watch and serve a path:

from pageit.tools import watch, serve
with watch(path, callback) as watcher:
    serve(path, port)  # wait for CTRL+C