[Tutor] returning a web page (and also path to web root)

Daniel Ehrenberg littledanehren at yahoo.com
Sun Dec 14 20:48:15 EST 2003


Barnaby Scott wrote:
> I am trying to write a cgi script in which under
> rare
> circumstances I want the user to see a particular
> web
> page (from the same server).
> 
> I am not very experienced and would be very grateful
> for help on the right way to tackle this - without
> knowing a sensible direction to go in I am likely to
> waste huge amounts of time developing a stupid or
> overly-complex solution!
> 
> Presumably if I just read the page in and spat it
> back
> out to the user, all the relative links, image
> sources
> etc would be wrong.
> 
> However I was a little reluctant to start messing
> with
> the SimpleHTTPServer module - a. because I find it
> daunting and b. I wondered if there was something
> altogether simple and obvious I could do.
> 
Try using the Twisted framework. Among several other
protocalls, Twisted can act as a web server. It is
written completely in Python so it's very portable.
With Twisted's web server, you can use static websites
or traditional CGI, but it's much more efficient to
use Twisted's own persistent framework with all of
these great templating and distributed object tools.

> One more quick question: is there an easy way of
> returning the actual path of the webserver's web
> root?
> (Forgive my terminology if it's not right - I mean
> the
> root directory as far as the someone accessing the
> site is concerned).

I'm not really sure what you mean. Don't you have to
define that on the web server software itself and it
isn't some kind of underlying thing available from
every program? This might be possible with something
like mod_python, but not in a more general way.

Daniel Ehrenberg

__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/



More information about the Tutor mailing list