wsgirouter3-weasyprint

WSGI routing library weasyprint plugin


Keywords
web, services, python, weasyprint
License
MIT
Install
pip install wsgirouter3-weasyprint==0.1.1

Documentation

Weasyprint plugin for wsgirouter3

Usage

Configure application to use plugin

def _generator(html_id: str, context: Any) -> str:
    # your choice of template engine


application = wsgirouter3.WsgiApp(router)
wsgirouter3_weasyprint.install(
    application,
    wsgirouter3_weasyprint.PdfConfig(html_generator=_generator)
)

Return instance of Pdf from endpoint

@router.get('/get', produces='application/pdf')
def get() -> Pdf:
    html_generation_ctx = {'context': 'variable'}
    return Pdf('html_template_id', html_generation_ctx)

Installation

$ pip install wsgirouter3_weasyprint