Python – How to redirect to another page in Python in CGIAr


If I want to redirect the user from a cgi script to a HTML page using core libraries from the following:

import cgi

Please could someone point me in the right direction. Nothing more. Simply redirect from cgi script to html page. How ever you would do this Python. If you have to physically write out the HTTP Response Headers to achieve this, then I would appreciate any info on how to do this.


Best Solution

You need to output one more header ("Status") in addition to the Location one, e.g.:

print "Status: 301 Moved",
print "Location:/"