Client-side HTML form processing with Python?

Jay Loden python at
Sun Aug 5 00:14:25 CEST 2007

goldtech wrote:
> I want to have an HTML form from a local local html file write a text
> field's data to a local text file.
> I have no client or server side tools like PHP, JAVA. I don't know
> JavaScript. I can not add anything to the workstation I am using. It's
> going to have to be a client-side solution - there's no CGI on the
> server, no PHP.
> It's XP with MS-Office, so I guess I have the usual active-x, and I
> have Python 2.1.
> Is there a way?  Thanks,
> Lee G.

Even if serving a local page, some kind of web server would be necessary in
order to process the request from the submitted form, and execute the Python CGI
script. I know you said you can't add anything to the workstation, but you must
be able to at least add Python scripts and html files, so perhaps you can get
away with adding a self-contained web server? I recommend TinyWeb ( ). It's only 53k and supports all
the basic webserver functions, including CGI.

You can drop TinyWeb in your working directory, start it up with a simple
shortcut or batch file, and then have your local HTML form submit to a CGI
script processed through TinyWeb. I've used it for a very similar project
before, it's so tiny and lightweight that it really doesn't get in the way, and
the CGI portion works just fine with Python.

If you really can't add anything at all (not even Python packages??), the only
other way to do this that I can come up with would be to implement your own
simplistic web server in Python that receives the incoming request. Twisted has
a CGI-enabled web server in it, and CGIHTTPServer also offers one. However,
CGIHTTPServer uses os.fork and is not available on Windows: - but you could
possibly use it as a starting point.

Other than the above the only suggestion I can give would be to search for
another way to approach your problem. For instance, using an hta or using a
Tkinter/wxWidgets GUI instead of an html form.


More information about the Python-list mailing list