Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A reusable app that serves static files for bottle apps

Project Description


bottle-servefiles can serve static files for your application.

I deceided to create this application to further my understanding of WSGI and how to build pluggable apps for the ecosystem.

bottle-servefiles aims to be a simple WSGI app that can be mounted into any powered app in order to serve static files from any url.

For instance in a regualar app you may have the code below to serve static files:

from bottle import route
import bottle


def static(filename):
    bottle.static_file(filename, root=...)

What I would like is to be able to mount a reusable static file handler on any path I chose within my application, without having to explicitly attach the path to the handler definition.

Ok I know that is pure nonsense but I had to come up with a compelling reason to build this thing in the first place.

So moving swiftly forward, with a static handler implemented as a pluggable bottle app, I would be able to do the following:

import bottle


myapp = bottle.default_app()
myapp.mount(bottle.load_app('servefiles'), '/media')

It doesn’t look like much, but with a pluggable app, it now becomes possible to configure the application (e.g. set the “root” directory) per mounted instance of the static file handler!




You can install upgrade or uninstall bottle-servefiles with these commands:

> pip install bottle-servefiles
> pip install -U bottle-servefiles
> pip uninstall bottle-servefiles

If you do not have pip you may use easy install:

> easy_install bottle-servefiles

If you do not have easy_install, you may download the piot source distribution archive. Extract it and run:

> python install

Example usage

This is a basic outline of how you would use bottle-servefiles to server static files from your application.

Create an application module “” with the contents:

import bottle

class MySite(object):
    def __init__(self, app=None): = app if app else bottle.default_app()

    def __call__(self, environ, start_response):
        return, start_response)

if __name__ == '__main__':
    mysite = MySite()'servefiles'), '/__media')
    bottle.debug(True), reloader=True)

Copyright (c) 2011 - Rudy Lattae. Released under the New BSD License.


Release History

Release History

This version
History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date (8.9 kB) Copy SHA256 Checksum SHA256 Source Oct 8, 2011

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting