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 <http://svn.saddi.com/flup/trunk>
.
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
flup.server.ajp
flup.server.ajp_fork
flup.server.fcgi
flup.server.fcgi_fork
flup.server.scgi
flup.server.scgi_fork
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:
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['Hello World!\n']
if __name__ == '__main__':
from flup.server.fcgi import WSGIServer
WSGIServer(myapp).run()
WSGI middleware
flup.middleware.error
flup.middleware.gzip
flup.middleware.session
Some WSGI middleware which may or may not be useful to other projects.
:)
An example of using all three:
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, 'wsgi-admin@example.com')
if __name__ == '__main__':
from flup.server.ajp import WSGIServer
WSGIServer(app).run()
Publisher
flup.publisher
flup.resolver.module
flup.resolver.importingmodule
flup.resolver.objectpath
A lightweight web framework originally inspired by mod_python's publisher module.
An unrealistic example (hello.py): ;)
def index(trans):
name = trans.session.get('name')
if name is None:
return 'Hello, anonymous!\n'
else:
return 'Hello, %s!\n' % name
def login(trans, name=None):
if name is not None:
trans.session['name'] = name
raise Redirect('./')
def logout(trans):
trans.session.invalidate()
return 'Goodbye!\n'
And then:
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
WSGIServer(app).run()