This Python package is a random collection of WSGI modules I've written. fcgi and publisher have long existed since I became interested in Python web programming a few years ago. They have been recently cleaned up and retrofitted with WSGI. The other modules just followed as I explored the possibilities of WSGI.

This package has no dependencies and installs with a simple distutils setup script. However, if you are running a version of Python less than 2.4, the use of forking WSGI servers requires the eunuchs module.

The Subversion repository is <>.

You can grab the latest snapshot here.

Here is news relating to flup, as well as an RSS feed of the same.

flup is distributed under a BSD-style license.

WSGI servers


Three sets of WSGI servers/gateways, which speak AJP 1.3, FastCGI, and SCGI. Each server comes in two flavors: a threaded version, and a forking version.

Example usage:

def myapp(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    return ['Hello World!\n']

if __name__ == '__main__':
    from flup.server.fcgi import WSGIServer

WSGI middleware


Some WSGI middleware which may or may not be useful to other projects. :)

An example of using all three:

from flup.middleware.session import MemorySessionStore, SessionMiddleware
from flup.middleware.gzip import GzipMiddleware
from flup.middleware.error import ErrorMiddleware

def myapp(environ, start_response):
    session = environ['com.saddi.service.session'].session
    count = session.get('count', 0) + 1
    session['count'] = count
    start_response('200 OK', [('Content-Type', 'text/plain')])
    return ['You have been here %d times!\n' % count]

sessionStore = MemorySessionStore()
app = SessionMiddleware(sessionStore, myapp)

app = GzipMiddleware(app)

app = ErrorMiddleware(app, '')

if __name__ == '__main__':
    from flup.server.ajp import WSGIServer



A lightweight web framework originally inspired by mod_python's publisher module.

An unrealistic example ( ;)

from flup.publisher import Redirect

def index(trans):
    name = trans.session.get('name')
    if name is None:
        return 'Hello, anonymous!\n'
        return 'Hello, %s!\n' % name

def login(trans, name=None):
    if name is not None:
        trans.session['name'] = name
    raise Redirect('./')

def logout(trans):
    return 'Goodbye!\n'

And then:

from flup.resolver.module import ModuleResolver
from flup.publisher import Publisher
from flup.middleware.session import ShelveSessionStore, SessionMiddleware

import hello
app = Publisher(ModuleResolver(hello))

app = SessionMiddleware(ShelveSessionStore(), app)

if __name__ == '__main__':
    from flup.server.scgi import WSGIServer

Copyright © 2005 Allan Saddi. All Rights Reserved.