Skip to content

andruskutt/wsgirouter3-weasyprint

Repository files navigation

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

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages