2degrees Developers

Announcing WSGI X-Sendfile: High-Performance File Transfer for Python/WSGI Applications

Gravatar of Gustavo Narea Written by Gustavo Narea
11 Apr 2013

I'm pleased to announce the first public release of WSGI X-Sendfile, a library that lets your Python/WSGI application serve static files via your Web server.

Modern Web servers like Nginx are generally able to serve files faster, more efficiently and more reliably than any Web application they host. These servers are also able to send to the client a file on disk as specified by the Web applications they host. This feature is commonly known as X-Sendfile.

This simple library makes it easy for any WSGI application to use X-Sendfile, so that they can control whether a file can be served or what else to do when a file is served, without writing server-specific extensions. Use cases include:

  • Restrict document downloads to authenticated users.
  • Log who’s downloaded a file.
  • Force a file to be downloaded instead of rendered by the browser, or serve it with a name different from the one on disk, by setting the Content-Disposition header.This code has been used in production for three years in our Django application, but is now being released as beta in case there are bugs that haven't become evident in our systems.

Get it while it's hot!


Tags: