Please Help with CGI Script!
Ben Ocean
zope at thewebsons.com
Fri Apr 27 16:02:51 EDT 2001
Hi,
I'm trying to cobble together my first CGI script and running into
problems. Here's the deal:
**an alien URL (around which I frame) will send me an HTTP_POST stream.
**I need to capture the stream
**I need to get the information to the client
How do I configure the URL the stream will come to? Easy enough on the
alien host's page. Let's say he posts to rightHere.html. What do I do:
build some kind of shell called by the same name? How do I hook it to the
cgi script?
Once I get it, how do I get the info to the client? I was thinking of
parsing it and reconfiguring it the way I want, then putting up a page
named according to the datestamp so that I could load up as many as the
client needed, then write a cron script to take them down after so long a
time. Probably just easier to send an email. How do?
TIA,
BenO
Script follows:
#!/usr/bin/python
import sys # just for debugging purposes
import cgi
import time
import string
import os
form = cgi.FieldStorage()
print 'Content-type: text/html\n\n'
# specify the filename of the page to send the dealership
Report = repr(time.time()) + ".html"
# read the entire file as a string
def main():
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
if (__name__ == "__main__"):
main()
More information about the Python-list
mailing list