Dumb-as-rocks WSGI serving using standard library

Discussion in 'Python' started by Ben Finney, May 22, 2006.

  1. Ben Finney

    Ben Finney Guest

    Howdy all,

    I'm trying to implement some new functionality for an existing PHP web
    application. Rather than writing a whole lot of stuff in PHP, and
    looking toward a future when more of the application can be rewritten
    more sanely, I'd like to write a Python program that generates the
    content and serves it up to the existing application via HTTP.


    The existing architecture is as expected:

    web client <--(HTTP)--> existing app

    with the existing app also talking to a database.

    The new functionality involves generating a PDF document from input
    parameters and returning it to the browser. Rather than nestle this
    into the existing PHP, I'd like the existing app to simply make an
    HTTP request to a single-purpose application server written in Python
    which generates the content and serves it back as the response body.

    This would insert into the above architecture behind the existing
    application:

    existing app <--(HTTP)--> request server <--(WSGI)--> content generator

    The bulk of the new functionality would be in the generation of the
    content from the input parameters.

    The request server would run locally on the machine, listening for
    HTTP requests and invoking the content generator via WSGI; the
    generated document would simply be served back as the HTTP response
    body.

    The existing application would then just need to gather the input
    parameters needed, feed them in an HTTP request to the request server,
    and feed back the response to the web client.


    I can see how writing the content generator to talk WSGI would be
    beneficial: the application can be re-used in other application
    contexts. The WSGI protocol is easy to follow.

    What I can't find is a simple recipe to serve a WSGI application with
    a dumb-as-rocks HTTP server, just using the standard Python library.

    The standard library includes BaseHTTPServer, which as far as I can
    tell doesn't know anything about WSGI.

    The don't seem to be any recipes posted to the Python Cookbook
    <URL:http://aspn.activestate.com/ASPN/Python/Cookbook/> with "wsgi" in
    them.

    Everything else that I can find leads to dependencies I don't want for
    flexibility I don't need: cherrypy, paste, et al.

    Any suggestions for how to serve up a simple WSGI application with
    just the standard library?

    --
    \ "A cynic is a man who, when he smells flowers, looks around for |
    `\ a coffin." -- Henry L. Mencken |
    _o__) |
    Ben Finney
    Ben Finney, May 22, 2006
    #1
    1. Advertising

  2. On Mon, 22 May 2006 18:18:34 +1000, Ben Finney wrote:

    [...]
    >
    > Everything else that I can find leads to dependencies I don't want for
    > flexibility I don't need: cherrypy, paste, et al.
    >
    > Any suggestions for how to serve up a simple WSGI application with
    > just the standard library?


    the easiest seems to be james: http://wsgiarea.pocoo.org/james/
    or
    flup: http://www.saddi.com/software/flup/ (for FCGI adapter)
    Stephan Diehl, May 22, 2006
    #2
    1. Advertising

  3. Ben Finney

    Damjan Guest

    > What I can't find is a simple recipe to serve a WSGI application with
    > a dumb-as-rocks HTTP server, just using the standard Python library.
    >
    > The standard library includes BaseHTTPServer, which as far as I can
    > tell doesn't know anything about WSGI.
    >
    > Everything else that I can find leads to dependencies I don't want for
    > flexibility I don't need: cherrypy, paste, et al.
    >
    > Any suggestions for how to serve up a simple WSGI application with
    > just the standard library?


    There's no WSGI http server in the std lib as of Python 2.4.

    Paste[1] provides one, wsgiref[2] (probably will be included in Python 2.5)
    provides a SimpleHTTPServer and CGI based WSGI servers.
    There's also WSGIUtils[3] that provides that.

    [1] http://pythonpaste.org/
    [2] http://svn.eby-sarna.com/wsgiref/
    http://www.artima.com/weblogs/viewpost.jsp?thread=158191
    [3] http://www.owlfish.com/software/wsgiutils/

    --
    damjan
    Damjan, May 22, 2006
    #3
    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. Thomas W

    WSGI-server in the standard distro?

    Thomas W, Aug 7, 2005, in forum: Python
    Replies:
    0
    Views:
    295
    Thomas W
    Aug 7, 2005
  2. Dave
    Replies:
    1
    Views:
    694
  3. Tool69
    Replies:
    10
    Views:
    490
    Martin v. Löwis
    May 25, 2008
  4. Phil Tomson

    A standard like WSGI for Ruby?

    Phil Tomson, Sep 22, 2006, in forum: Ruby
    Replies:
    6
    Views:
    149
    M. Edward (Ed) Borasky
    Sep 22, 2006
  5. Jerry C.
    Replies:
    8
    Views:
    214
    Uri Guttman
    Nov 23, 2003
Loading...

Share This Page