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

Search Discussions

  • Jay Loden at Aug 4, 2007 at 10:17 pm

    Paul Rubin wrote:
    goldtech <goldtech at worldpost.com> writes:
    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.
    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
  • Gabriel Genellina at Aug 5, 2007 at 10:52 am
    En Sat, 04 Aug 2007 19:17:35 -0300, Jay Loden <python at jayloden.com>
    escribi?:
    Paul Rubin wrote:
    goldtech <goldtech at worldpost.com> writes:
    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
    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)

    --
    Gabriel Genellina
  • Jay Loden at Aug 5, 2007 at 4:54 pm

    Gabriel Genellina wrote:
    En Sat, 04 Aug 2007 19:17:35 -0300, Jay Loden <python at jayloden.com>
    escribi?:
    Paul Rubin wrote:
    goldtech <goldtech at worldpost.com> writes:
    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
    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.
    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedAug 4, '07 at 7:58p
activeAug 5, '07 at 4:54p
posts4
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase