Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > simplest way to create simple standalone wsgi server without importwsgi_lib.server

Reply
Thread Tools

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

 
 
Gelonida
Guest
Posts: n/a
 
      01-31-2011
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




 
Reply With Quote
 
 
 
 
Jean-Paul Calderone
Guest
Posts: n/a
 
      02-01-2011
On Jan 31, 5:28*pm, Gelonida <(E-Mail Removed)> wrote:
> 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
 
Reply With Quote
 
 
 
 
Gelonida
Guest
Posts: n/a
 
      02-01-2011
On 02/01/2011 03:07 AM, Jean-Paul Calderone wrote:
> On Jan 31, 5:28 pm, Gelonida <(E-Mail Removed)> wrote:
>> 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>


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.


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



 
Reply With Quote
 
Jean-Paul Calderone
Guest
Posts: n/a
 
      02-01-2011
On Feb 1, 2:01*pm, Gelonida <(E-Mail Removed)> wrote:
> On 02/01/2011 03:07 AM, Jean-Paul Calderone wrote:
>
>
>
> > On Jan 31, 5:28 pm, Gelonida <(E-Mail Removed)> wrote:
> >> 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>

>
> 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
 
Reply With Quote
 
Gelonida
Guest
Posts: n/a
 
      02-01-2011
On 02/01/2011 11:36 PM, Jean-Paul Calderone wrote:
>>
>>> twistd -n web --port <port> --wsgi <application>

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

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





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create standalone Windows program with simple graphics? Poster28 Python 9 04-20-2009 11:04 AM
Very simple WSGI question Matthew Wilson Python 1 11-22-2008 02:40 PM
Simplest way (or module) to tweak query in CGI server-side validation Jerry Krinock Perl Misc 10 07-14-2008 02:01 AM
Simplest way to do Python/Ajax with server and client on same machine? Kenneth McDonald Python 2 12-29-2006 08:00 PM
simplest way to password protect website with SQL Server Brent Burkart ASP .Net 5 10-16-2003 05:34 AM



Advertisments