CGI Redirect

Ben Ocean zope at thewebsons.com
Tue May 1 13:01:50 EDT 2001


At 07:00 PM 5/1/2001 +0200, you wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>
>Hello Ben,
>
>Tuesday, May 01, 2001, 6:50:35 PM, you wrote:
> >>This should work without the trailing semicolon in Python (assuming
> >>that
> >>nothing outputs any other headers before, of course!).
> > Ah, yes, but in order to get the form to not toss up an HTTP 500
>server
> > error I have to put in the following:
>
> > print "Content-type: text/html\n\n"
>
>Uuuh? Normally Content type and location headers shouldn't be mixed as
>the first one will disable all the others... For me, Location alone
>works (Apache 1.3.19).

Here's my code. Can you tell me where I'm going wrong? (Everything gets 
replaced like it should, it's just the aforementioned error.)
 >>>
#!/usr/bin/python

import os, sys, cgi, string

FormData = cgi.FieldStorage()
print "Content-type: text/html\n\n"

Disallowed = ['\nTo:', '\nCc:', '\nBcc:']

FormData = open("/apache/vhosts/bladechevy/New/test.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-\"", "."), "\" value-\"", "----"), 
"\">", ".")
   formstuff = string.join([formstuff,line])
FormData.close()                    # close the file
import smtplib
server = smtplib.SMTP("localhost")
server.sendmail("beno at thewebsons.com", "beno at thewebsons.com", formstuff)
server.quit()

print "Location:http://bladechevy.com/"
<<<
TIA,
BenO





More information about the Python-list mailing list