My First CGI Script
Ben Ocean
zope at thewebsons.com
Thu Apr 26 23:20:15 EDT 2001
Hi;
I have several questions concerning how to write a cgi script. I will be
receiving an HTTP_POST feed from an alien Web page I frame around. In other
words, the visitor fills out a form on the alien Web page and the data gets
sent back to me. Let's say I have this sent to kelleyblue.html. I need to
capture that feed and convert it into a page that I am labeling by
timestamp. Here's the code and it works as far as it goes:
>>>
#!/usr/bin/python
import cgi
import time
import string
import os
# specify the filename of the page to send the dealership
Report = repr(time.time()) + ".html"
# read the entire file as a string
def PrintPage():
start = "<html><body>\nHere's the data a potential customer requested
from the Kelley Blue Book link on your Web site:<br> <br>\n"
FormData = open("/apache/vhosts/bladechevy/cgi-bin/kelleyblue.html","r")
formstuff = ""
while FormData.readline():
safe = string.maketrans("`|~!@#$%^&*()_+=:;{}[]",
"----------------------")
line =
string.replace(string.replace(string.replace(string.translate(FormData.readline(),
safe), "<input type-\"hidden\" name-\"", "<tr><td>"), "\" value-\"",
"</td><td>"), "\">", "</td></tr>\n")
formstuff = string.join([formstuff,line])
end = "</body></html>\n"
all = string.join([start,formstuff,end])
FormData.close() # close the file
<<<
Can you help me fill in the blanks of
**How do I capture the data?
**How do I write a Web page on the fly and assign it the name *Report*?
TIA,
BenO
More information about the Python-list
mailing list