This continues the example from last time, using the built-in server on OS X and trying to understand how to transmit data from a form to a Python script. The form and the script files that I edit are on my Desktop, and after editing I have to remember to do:
I have Web Sharing turned on, with Apache set to only listen to localhost. I point Safari to:
and I get what's in the graphic. The form text is:
Actually, in the source for this post I changed all the less-than symbols to
<
as usual. There has to be a blank line after the first one with Content-type, or I get an error. The script is very simple. It uses
os.environ
to get values from the "environment":If I type data into the form and then hit submit, the form data goes to the script, which reads it and sends the result back as a web page:
So, it looks pretty good.
There is a big thing missing, however. I do not yet know how to obtain the data from the
textarea
. Baby steps.