Skip to content

Latest commit

 

History

History
61 lines (42 loc) · 1.41 KB

api.rst

File metadata and controls

61 lines (42 loc) · 1.41 KB

Script API v

Cleaning & Rendering

It's easy to include :py~pageit.render.Pageit in your own scripts:

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

Watching for File Changes

Use :py~pageit.tools.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

watchdog for the cross-platform directory-watching library

Basic HTTP Server

Use :py~pageit.tools.serve to serve up files on a given port:

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

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

Python Modules

api/render api/tools api/namespace