tags:

views:

212

answers:

4

I need to write a browser interface for an application running embedded on a single board computer (Gumstix Verdex for anyone who's interested), so I won't be able to use any web frameworks due to space and processor constraints (and availability for the environment I'm running in). I'm limited to the core Python and cgi modules to create pages that will communicate with a C++ application.

Can anyone recommend a good resource (web or book form, but books are preferred) for learning CGI programming in Python?

What I need the application to do is fairly simple. I have a C++ program running on the same device and I need to create a browser based user interface so the configuration settings of that application can be changed. The UI needs to communicate with the C++ application, where the final data validation will be done. Preliminary validation can be done on the UI using Javascript, then again on the server using Python, but the final validation has to be done in the application itself, since it's getting its initial config from a file anyway. The configuration data takes all forms (booleans, ints, floats, and strings).

+3  A: 

It's fairly easy, this should get you up to date very quickly

http://www.python.org/doc/essays/ppt/sd99east/sld038.htm

Vinko Vrsalovic
+2  A: 

One of the biggest resources for CGI programming is the CGI homepage. Once you're done with that, familiarizing yourself with the cgi and cgitb modules should be your next task.

But don't discount learning WSGI (libref) and using a CGI-to-WSGI adaptor such as flup.

Ignacio Vazquez-Abrams
+1 for WSGI -- it makes life much simpler.
S.Lott
A: 

All found via google...

And take a look at pyblosxom as well: http://pyblosxom.svn.sourceforge.net/viewvc/pyblosxom/ it's a weblog system written in python, uses CGI.

Zsolt Botykai
I can search google myself. I'm asking for resources you've used that you can recommend.
Bill the Lizard
I used the devshed link as a tutorial, then dived into pyblosxom.
Zsolt Botykai
The devshed one is good to get your feet wet.
projecktzero
+1  A: 

What I don't understand is why you insist on CGI, because that's a Common Gateway Interface meant to be used in conjunction with a webserver like apache, which you surely do not have on that device.

I would suggest you use wsgiref.simple_server which is a single threaded buildin webserver shipped with python 2.5 and up (if you have 2.4 or below you can d/l wsgiref from pypi, it is a pure python package). That way you can also sidestep messy CGI programming and write a wsgi application:

from wsgiref.simple_server import make_server

def application(environ, start_response):
    start_response('200 OK', [
        ('Content-Type', 'text/plain'),
    ])
    return ['Hello World!']

httpd = make_server('', 8000, application)
httpd.serve_forever()
Florian Bösch
The device comes with Boa Webserver pre-installed and I can get Python Version 2.4.2 to work on it. The OS is a tiny version of Linux called OpenEmbedded that not all packages are currently available for.
Bill the Lizard