Client-side HTML form processing with Python?

G

goldtech

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.
 
P

Paul Rubin

goldtech said:
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.

Oh wait, you're trying to write html on a remote web server that saves
files on the client? Hmm, what browser? Anyway you're going to have
to use browser scripting and use browser-dependent mechanisms to get
the user's permission to access the file system. It is messy but
necessary. Granting arbitrary file system access to remote web
servers would be a huge security hole.
 
J

Jay Loden

goldtech said:
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 (
http://www.ritlabs.com/en/products/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:
http://www.python.org/doc/1.5.2p2/lib/module-CGIHTTPServer.html - 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
http://msdn2.microsoft.com/en-us/library/ms536496.aspx or using a
Tkinter/wxWidgets GUI instead of an html form.

-Jay
 
G

goldtech

Looks like Tkinter is the way to do it.

There's always a way with Python - good stuff!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,052
Members
48,769
Latest member
Clifft

Latest Threads

Top