Submit web form only client-side with Python? COM?

G

goldtech

Say I have have an HTML form , the user hits the submit button and I
what text they enetered into a HTML form field is written to a file.

But I don't have PHP, JAVA the usual client or server sided layers to
write the data to a file, and I'm not to keen on JavaScript. Note: I
can not add or download anything, I must use what I have.

But I have Python 2.1 and I'm on a WinXP desktop with the win32.com,
and usual active-x objects, MS-Office ect - what'd normally locally on
an XP work station.

So I can present the user with an HTML form in it - but how can I
write the form data to a local file on my work station?

If there isn't a web form way, could there be another way to get a box
to come up with input fields with the capability to submit the data to
a file?

Thanks,
Lee G.
 
P

Paul Rubin

goldtech said:
So I can present the user with an HTML form in it - but how can I
write the form data to a local file on my work station?

The simplest way is with the cgi and CGIHTTPServer modules. You'd
write your form in an html file, with the target set to a Python
script that you'd write as a cgi. Then you'd write a trivial CGI HTTP
server (look at the example code in the comments) with CGIHTTPServer.
The user would point their browser at your server (you could make a
desktop shortcut for that), the browser shows the html file, and the
submit button sends the form contents to your cgi.

This is very basic, old-school web programming, not as flexible or
high-performance as using the fancy frameworks, but a lot simpler for
limited applications like what you're describing.
 
J

Jay Loden

Paul said:
The simplest way is with the cgi and CGIHTTPServer modules. You'd
write your form in an html file, with the target set to a Python
script that you'd write as a cgi. Then you'd write a trivial CGI HTTP
server (look at the example code in the comments) with CGIHTTPServer.
The user would point their browser at your server (you could make a
desktop shortcut for that), the browser shows the html file, and the
submit button sends the form contents to your cgi.

This is very basic, old-school web programming, not as flexible or
high-performance as using the fancy frameworks, but a lot simpler for
limited applications like what you're describing.

CGIHTTPServer is not available on Windows (OP said they are on Win XP) due to
use of fork and exec to execute the CGI. I suggested a few other options in my
reply, but unfortunately CGIHTTPServer is not an option for this task.

-Jay
 
G

Gabriel Genellina

CGIHTTPServer is not available on Windows (OP said they are on Win XP)

CGIHTTPServer does work on Windows (even on Python 2.1, as far as I can
go) and using it might be simple enough.
due to
use of fork and exec to execute the CGI.

CGIHTTPServer uses popen2 or popen3 if available.
I suggested a few other options in my
reply, but unfortunately CGIHTTPServer is not an option for this task.

I can't see any other reply from you on this thread... (I'm using the
gmane newsgroup interfase)
 
J

Jay Loden

Gabriel said:
CGIHTTPServer does work on Windows (even on Python 2.1, as far as I can
go) and using it might be simple enough.

Hrm, if so then it's a documentation bug. That's actually good news then in this
case :)
(see http://www.python.org/doc/2.1/lib/module-CGIHTTPServer.html )

[snip...]
I can't see any other reply from you on this thread... (I'm using the
gmane newsgroup interfase)

It's under the title "Client-side HTML form processing with Python?", apparently
the same post is listed twice or something like that.

-Jay
 

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

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top