Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

django-htmlmin: Reduzindo tamanho do response com Python

1,856 views

Published on

Lighting talk apresentada durante o FISL, na sessão de lighting talks da comunidade Python Brasil.

Published in: Technology
  • Be the first to comment

django-htmlmin: Reduzindo tamanho do response com Python

  1. 1. django-htmlmin Reduzindo o tamanho do seu response com Python @franciscosouzaFriday, July 1, 2011
  2. 2. #cobrateam • Não da tempo :PFriday, July 1, 2011
  3. 3. #cobrateam • Não da tempo :PFriday, July 1, 2011
  4. 4. #cobrateam • Não da tempo :P Já falei!Friday, July 1, 2011
  5. 5. Uma função from htmlmin.minify import html_minify print html_minify(conteudo)Friday, July 1, 2011
  6. 6. E o Django?Friday, July 1, 2011
  7. 7. view decorator from htmlmin.decorators import minified_response @minified_response def home(request): return render_to_response(home.html)Friday, July 1, 2011
  8. 8. middleware MIDDLEWARE_CLASSES = ( # other middleware classes htmlmin.middleware.HtmlMinifyMiddleware, )Friday, July 1, 2011
  9. 9. Indo além... from functools import wraps from htmlmin.minify import html_minify def minified_response(function): @wraps(function) def minified_view(*args, **kwargs): return_value = function(*args, **kwargs) if type(return_value) == unicode: return html_minify(return_value.encode(utf-8)) return return_value return minified_viewFriday, July 1, 2011
  10. 10. Indo além... @minified_response def home(request): return render_template(home.html)Friday, July 1, 2011
  11. 11. Obrigado! cobrateam.info github.com/cobrateam/django-htmlminFriday, July 1, 2011

×