Handling static content

Using Colubrid you can handle static content quite easily. All you have to do is to add the StaticExports middleware to your application.

A small example application is this:

import os
from colubrid import PathApplication, HttpResponse, execute
from colubrid.server import StaticExports

class MyApplication(PathApplication):

    def show_index(self, *args):
        return HttpResponse('Welcome from the Index Page')

app = MyApplication
app = StaticExports(app, {
    '/favicon.ico': './shared/favicon.ico',
    '/static': './shared'
})

if __name__ == '__main__':
    execute(app)

This is enough to map ./shared to http://myhost/myapp/static and ./shared/favicon.ico to http://myhost/myapp/favicon.ico.

Last Change: 10 Sep 2006 17:12:27 | show source