By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,205 Members | 1,064 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,205 IT Pros & Developers. It's quick & easy.

Dumb-as-rocks WSGI serving using standard library

P: n/a
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

May 22 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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)

May 22 '06 #2

P: n/a
> 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/viewpo...?thread=158191
[3] http://www.owlfish.com/software/wsgiutils/

--
damjan
May 22 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.