473,671 Members | 2,251 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dumb-as-rocks WSGI serving using standard library

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.activestat e.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
2 1396
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
> 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 SimpleHTTPServe r 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
2506
by: squash | last post by:
a dumb question i had on my mind: Say you have a dynamically created web page . Isn't it more secure to write it in php since a visitor will not be able to tell it is dynamically created? But if you write it in perl, you have to put it in your cgi-bin which automatically means it's a dynamically generated page? security by obscurity . Is this true or hardly means anything? thx!
3
1470
by: ed | last post by:
I've just started working with .Net, so appologize for what is probably a really dumb question. Did Windows XP originally come with the .Net framework installed, and if so which version? thanks in advance, ed
2
2269
by: InvisibleMan | last post by:
Hi, I feel a little dumb for asking this (considering im writing TSQL) but there doesn't seem to be any definitive answers on the search engines... Okay I understand that if you open the ADO connection that you close it with: adoCon.Close Set adoCon = Nothing
2
1297
by: TGF | last post by:
How do you copy a String type into a native char buffer? Dumb question, but not sure how to do it :( TGF
4
1320
by: Stelrad Doulton | last post by:
Hi, Apologies if this isn't the correct forum. I am writing a communication solution (actually on the Compact Framework) based on HttpWebRequests hooking up with custom handlers on the server side. My dumb question is this: how reliable is http? For example if I use PUT and call GetResponse on my request object with no problem, can I guarantee that every byte of my file will always arrive at the web server?
1
1153
by: Chris | last post by:
Dumb question about c# web services Posted on: 11/30/2005 12:14:16 Ok guys, here is what I am trying to do or what I need to know. I am creating a webservice called db_update. This webservice will have a couple of methods that allow it to make updates to a db.
2
1236
by: Rudy | last post by:
Hi All! A real dumb question, but should be easy, I hope. I created a custom message box, by creating a form. I just want a "OK" button on the message box to close the message box out. I tried close, but it doesn't work. How do I close this message box? Thanks! Rudy
4
1297
by: rodchar | last post by:
hey all, i've read wikipedia's version and still kinda fuzzy, can someone please give me a dumb down version of imperative vs declartive programming? thanks, rodchar
4
1706
by: theapeman | last post by:
Sorry to bore everyone with this question, which I'm sure is the equivalent of "Please help! What letter comes between C and E in the alphabet?" but seriously, if you really didn't know that, I don't know if there's a single google search in the world that would actually help you... Anyway, here it is: I'm writing a Perl script that uses the Expect module to open Firefox, and then I want to send Firefox a "CTRL+RightArrow" command, like...
0
8390
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8911
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8819
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8597
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8667
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6222
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5692
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2048
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.