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

Discussion in 'Python' started by Gelonida, Jan 31, 2011.

  1. Gelonida

    Gelonida Guest

    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
    Gelonida, Jan 31, 2011
    #1
    1. Advertising

  2. Re: simplest way to create simple standalone wsgi server withoutimport wsgi_lib.server

    On Jan 31, 5:28 pm, Gelonida <> 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
    Jean-Paul Calderone, Feb 1, 2011
    #2
    1. Advertising

  3. Gelonida

    Gelonida Guest

    Re: simplest way to create simple standalone wsgi server withoutimport wsgi_lib.server

    On 02/01/2011 03:07 AM, Jean-Paul Calderone wrote:
    > On Jan 31, 5:28 pm, Gelonida <> 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
    Gelonida, Feb 1, 2011
    #3
  4. Re: simplest way to create simple standalone wsgi server withoutimport wsgi_lib.server

    On Feb 1, 2:01 pm, Gelonida <> wrote:
    > On 02/01/2011 03:07 AM, Jean-Paul Calderone wrote:
    >
    >
    >
    > > On Jan 31, 5:28 pm, Gelonida <> 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
    Jean-Paul Calderone, Feb 1, 2011
    #4
  5. Gelonida

    Gelonida Guest

    Re: simplest way to create simple standalone wsgi server withoutimport wsgi_lib.server

    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.
    Gelonida, Feb 1, 2011
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brent Burkart
    Replies:
    5
    Views:
    788
    Jerry III
    Oct 16, 2003
  2. Kenneth McDonald
    Replies:
    2
    Views:
    653
    John J. Lee
    Dec 29, 2006
  3. Poster28
    Replies:
    9
    Views:
    326
    Poster28
    Apr 20, 2009
  4. Milca
    Replies:
    2
    Views:
    333
    Milca
    Apr 14, 2005
  5. Jerry Krinock
    Replies:
    10
    Views:
    250
Loading...

Share This Page