HTML Prettifier

1
2
3
4
5
6
7
8
from BeautifulSoup import BeautifulSoup

class Prettify(object):
    def process_response(self, request, response):
        if response.has_header('Content-Type') and response['Content-Type'].startswith('text/html'):
            response.content = BeautifulSoup(response.content).prettify()
        
        return response

More like this

  1. Prettify HTML body contents in HTTP response by n1k0 2 years, 6 months ago
  2. Template Filter: Add indentation by Chuck Harmston 3 years, 9 months ago
  3. urlize HTML by maguspk 3 years ago
  4. Showell markup--DRY up your templates by showell 3 years, 6 months ago
  5. Whore links by nathan 6 years, 3 months ago

Comments

(Forgotten your password?)