django-htmlmin: Reduzindo tamanho do response com Python
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

django-htmlmin: Reduzindo tamanho do response com Python

on

  • 1,891 views

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

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

Statistics

Views

Total Views
1,891
Views on SlideShare
1,889
Embed Views
2

Actions

Likes
1
Downloads
8
Comments
0

2 Embeds 2

https://twitter.com 1
http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

django-htmlmin: Reduzindo tamanho do response com Python Presentation Transcript

  • 1. django-htmlmin Reduzindo o tamanho do seu response com Python @franciscosouzaFriday, July 1, 2011
  • 2. #cobrateam • Não da tempo :PFriday, July 1, 2011
  • 3. #cobrateam • Não da tempo :PFriday, July 1, 2011
  • 4. #cobrateam • Não da tempo :P Já falei!Friday, July 1, 2011
  • 5. Uma função from htmlmin.minify import html_minify print html_minify(conteudo)Friday, July 1, 2011
  • 6. E o Django?Friday, July 1, 2011
  • 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. middleware MIDDLEWARE_CLASSES = ( # other middleware classes htmlmin.middleware.HtmlMinifyMiddleware, )Friday, July 1, 2011
  • 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. Indo além... @minified_response def home(request): return render_template(home.html)Friday, July 1, 2011
  • 11. Obrigado! cobrateam.info github.com/cobrateam/django-htmlminFriday, July 1, 2011