Forked from https://bitbucket.org/luke/static/
A really simple WSGI way to serve static (or mixed) content.
See docstrings of static module for details.
Following features are added:
Used for html 404 errors.
Example:
app = static.Cling('.', not_found=static.StatusApp('404 Not Found', file='./404.html'))
Automatically detects and sends if gzipped content is
requested and available. Example: index.html
tries to find index.html.gz
in the same directory.
Gzip is disbaled for Pre SP2 IE6 and IE5 browsers. Read more here: http://sebduggan.com/blog/ie6-gzip-bug-solved-using-isapirewrite/
Pushing beyond gzipping is implemented now. Read more about it here: http://developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
For better performance. Trying to keep syntax similar to Apache's
ExpiresByType
. You can specify the expires headers in
seconds against each mime type.
Example:
EXPIRES = [
# html
('text/html', 0), # No cache
# feed
('application/xml', 60*60), # 1 hour
# favicon
('image/x-icon', 7*24*60*60), # 1 week
# media
('image/gif', 30*24*60*60), # 1 month
('image/jpeg', 30*24*60*60), # 1 month
('image/png', 30*24*60*60), # 1 month
# CSS and Javascript
('application/javascript', 365*24*60*60), # 1 year
('text/css', 365*24*60*60), # 1 year
]
app = static.Cling('.', expire_headers=EXPIRES)
For better browser rendering performance. Again, trying to keep
it similar to Apache's AddCharset
. Charset can be set for filename
patterns (file extensions in most of the cases).
Example:
CHARSETS = [
('*.html', 'UTF-8'), # Default for html files
('*.ja.html', 'SHIFT_JIS'),
]
app = static.Cling('.', charsets=CHARSETS)
Custom headers can be sent for matching file patterns. Use *
to
send a specific header with all files.
Example:
CUSTOM_HEADERS = [
('*.html', "X-UA-Compatible", "IE=Edge,chrome=1"),
]
app = static.Cling('.', custom_headers=CUSTOM_HEADERS)
Here are the suggested features for future:
- Cache Busting using filename rewrites instead of query strings (http://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/)
Created and maintained by Luke Arno [email protected]
Modified by Irfan Ahmad http://i.com.pk/
Copyright (C) 2006-2009 Luke Arno - http://lukearno.com/
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to:
The Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Luke Arno can be found at http://lukearno.com/