simplest way to create simple standalone wsgi server without import wsgi_lib.server

Jean-Paul Calderone calderone.jeanpaul at
Tue Feb 1 17:36:45 EST 2011

On Feb 1, 2:01 pm, Gelonida <gelon... at> wrote:
> On 02/01/2011 03:07 AM, Jean-Paul Calderone wrote:
> > On Jan 31, 5:28 pm, Gelonida <gelon... at> wrote:
> >> Hi,
> >> Normally I use following code snippet to quickly test a wsgi module
> >> without a web server.
> >> import wsgi_lib.server
> >>, port=port)
> >> However Now I'd like to test a small wsgi module on a rather old host
> >> ( Python 2.4.3 ) where I don't have means to update python.
> >> Is there any quick and easy code snippet / module, performing the same
> >> task as my above mentioned lines?
> >> Thanks in advance for any hints
> > You didn't mention why you can't update Python, or if that means you
> > can't install new libraries either.  However, if you have Twisted 8.2
> > or newer, you can replace your snippet with this shell command:
> >     twistd -n web --port <port> --wsgi <application>
> Thanks Jean-Paul
> The problem is rather simple. The host in question is not 100% under my
> control. I can request to have packages installed if they're in the list
> of available packages.
> python 2.4 is part of it. twisted is not
> In the worst case I could request the installation of python virtualenv,
> the entire gcc tool chain and try to compile twisted,
> or wsgilib, but I wondered whether there isn't a simple pure python way
> of starting a wsgi server for test purposes.

You may be able to install Twisted (or even wsgilib) in your home
directory.  For example, the command:

    python --prefix ~/.local

will install Twisted (or maybe wsgilib) in ~/.local/lib/python2.4/site-
packages/.  Add that to your PYTHONPATH (eg in your .bashrc) and
you're basically all set.  Also, though Twisted has some extension
modules, they're optional.  So you should be fine without a compiler,
*except* that distutils doesn't cope so well with certain cases.  If
you find " install" fails for some reason, you can also just
add the unpacked source directory to PYTHONPATH and run it in-place
without installation.


More information about the Python-list mailing list