django-htmlmin: Reduzindo tamanho do response com Python

1,715 views
1,648 views

Published on

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

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,715
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

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

×