CGI Redirect
Steffen Ries
steffen.ries at sympatico.ca
Wed May 2 07:12:08 EDT 2001
Ben Ocean <zope at thewebsons.com> writes:
> >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.)
I did not follow the whole thread, so I may miss something...
> >>>
> #!/usr/bin/python
>
> import os, sys, cgi, string
>
> FormData = cgi.FieldStorage()
> print "Content-type: text/html\n\n"
The two "\n\n" produce two empty lines, where the first one separates
the HTTP header from the body.
> 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/"
This goes into the body of the HTTP get-response. IOW the line is
interpreted as regular HTML text and has no special meaning for the
browser.
What you want is:
--8<--
print "Content-type: text/html"
# this line does not do anything, but is harmless
...
print "Location: http://bladechevy.com/"
--8<--
hth,
/steffen
--
steffen.ries at sympatico.ca <> Gravity is a myth -- the Earth sucks!
More information about the Python-list
mailing list