[Tutor] cgi redirection
Charlie Clark
charlie@begeistert.org
Tue Mar 25 10:53:04 2003
On 2003-03-25 at 12:31:44 [+0100], tutor-request@python.org wrote:
> Message: 10
> From: Alan Trautman <ATrautman@perryjudds.com>
> To: tutor@python.org
> Subject: RE: [Tutor] cgi redirection
> Date: Mon, 24 Mar 2003 14:45:44 -0600
>
>
> If you are working on IIS and have complete control over the server you
> can install php which will give you all the redirection commands you
> would ever need (well as good as the web gets). It also runs quite well
> on Linux and BSD. Sorry this isn't much help on CGI but I forgot all that
> as soon as I had mods and active scripting.
sorry, but I have to object to this answer here. I much prefer using Python
for cgi/web than PHP and you can have mod_python for Apache just like you
can have mod_PHP. You can also use Python with ASP instead of Visual Basic
if using MS IIS but it's news to me that Microsoft has ported to Unix.
But none of that is answer to the initial question!
Magnus has provided a good reply based on using HTTP-REFRESH which works
with virtually any browser but I initially wasn't sure what the question
was. What do you mean by redirection?
The problem is that HTTP is stateless and relies on GET requests from
browsers. A server can only send a page to a browser when it receives a
request from that browser. Redirection can be done in the web server but
this usually means that when a page is requested another is returned. When
you call a cgi script you can only return one page and that is by
essentially by printing it in which case Magnus' answer is the best way. An
alternative might be to have the cgi call a page and print it - this is a
bit how Google's archive works - but this isn't very common.
If you're using IIS and .ASP you should have access to all the functions of
the server via Python:
http://search.microsoft.com/gomsuri.asp?n=1&c=rp_Results&target=http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B276494
which will also include how to access server-side redirection which happens
in the link itself.
If you want to move to Unix you may still be able to use .ASP; there is an
ASP engine for Linux from Chilisoft I believe. However, IIS + ASP really
isn't cross-platform. If you're used to it I'd stick to it as porting the
functionality to another language or application server (IIS + ASP is
considerably more than a straight webserver) is likely to be labour
intensive. If you are looking for a cross-platform solution you might want
to look at Zope (www.zope.org). Zope is a an application server written in
Python which will run on most platforms with or without an additional web
server (IIS or Apache). The API has an explicit redirect() function.
Hope that helps but if not please be a little more specific.
Charlie