Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python/Tornado - compressing static files

For django projects there is an awesome tool called django-compressor. It combines all js or css files under compress template tag into single cached file, like this:

{% load compress %}

{% compress css %}
<link rel="stylesheet" href="/static/css/one.css" type="text/css" charset="utf-8">
<style type="text/css">p { border:5px solid green;}</style>
<link rel="stylesheet" href="/static/css/two.css" type="text/css" charset="utf-8">
{% endcompress %}

I'm wondering if there is anything like this for tornado projects? Or maybe any workaround/alternative solution?

I've found this project on github, but it's no longer maintained.

like image 992
alecxe Avatar asked Apr 20 '13 20:04

alecxe


1 Answers

Take a look at tornado_utils, it should do what you want. Especially take look at tornado_static.py

tornado_static is a module for displaying static resources in a Tornado web application.

It can take care of merging, compressing and giving URLs ideal renamings suitable for aggressive HTTP caching.

like image 138
Aldarund Avatar answered Oct 05 '22 11:10

Aldarund