A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/092711.html below:

My First CGI Script

My First CGI ScriptBen 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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4