Skip to content

Instantly share code, notes, and snippets.

@chadwhitacre chadwhitacre/
Last active Dec 20, 2015

What would you like to do?
"""This is an Aspen hook for supporting PJAX.
Install it in your project's like so:
website.hooks.outbound += [aspen_pjax.outbound]
from pyquery import PyQuery as pq #
def outbound(response):
"""Do PJAX by pulling an element out of the rendered page.
if not response.headers.get('Content-Type', '').startswith('text/html'):
if response.request.headers.get('X-PJAX') is None:
if response.request.headers.get('X-PJAX-CONTAINER') is None:
selector = response.request.headers['X-PJAX-CONTAINER']
response.body = pq(response.body)(selector).html().encode('utf-8')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.