PathApplication

This application type is very basic and only meaningful in small scripts:

from colubrid import PathApplication, HttpResponse, execute

class MyApplication(PathApplication):

    def show_index(self, *args):
        return HttpResponse('You\'ve requested the index page.')

    def show_downloads(self, *args):
        if args:
            response = 'You\'ve requested file #%s' % args[0]
        else:
            response = 'You\'ve requested the downloads page.'
        return HttpResponse(response)

app = MyApplication

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

When the user requests / or /index/ the application will call show_index. Additional path paramters (e.g. /index/this/is/a/test/) will end up in the args list.

This application type automatically appends a slash to the url.

Last Change: 17 Apr 2006 13:42:39 | show source