simplest way to create simple standalone wsgi server without importwsgi_lib.server

G

Gelonida

Hi,

Normally I use following code snippet to quickly test a wsgi module
without a web server.

import wsgi_lib.server
wsgi_lib.server.run(application, 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
 
J

Jean-Paul Calderone

Hi,

Normally I use following code snippet to quickly test a wsgi module
without a web server.

import wsgi_lib.server
wsgi_lib.server.run(application, 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>

<application> is the fully-qualified Python name of your application
object. So, for example if you have a module named "foo" that defines
an "application" name, you would pass "foo.application".

Jean-Paul
 
G

Gelonida

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.
 
J

Jean-Paul Calderone

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 setup.py --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 "setup.py install" fails for some reason, you can also just
add the unpacked source directory to PYTHONPATH and run it in-place
without installation.

Jean-Paul
 
G

Gelonida

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

python setup.py --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 "setup.py install" fails for some reason, you can also just
add the unpacked source directory to PYTHONPATH and run it in-place
without installation.

Thanks a lot you gave me some new ideas.

I made first attempts with virtualenv
and easy_install

no module with C-code can be installed (some issue with tool chain)

- wsgilib installation failed therefore
- twisted installation failed therefore

I untarred twisted and tried to run twistd.

it complains about missing zope.interface
installing of zope.interface fails also with gcc error.

It seems I am currently stuck until I find a simplistic python only
solution for quick standalone wsgi_module tests.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top