a little more help with python server-side scripting

Steve Holden steve at holdenweb.com
Wed Feb 22 00:57:53 EST 2006


John Salerno wrote:
> Steve Holden wrote:
> 
> 
>>If the script ran, you will now know waht version of Apaceh you're 
>>running with!
> 
> 
> Well, the script did seem to run, but I'm still not sure if this is what 
> I'm ultimately after. This allows me to run Python script files, which 
> is good, but what I really want to do is write bits of Python code in my 
> HTML files (as a means to include headers and footers, for example). So 
> these bits of Python code will basically be like a PHP include() 
> function that calls another HTML file which contains the header/footer 
> HTML to insert into the calling file. This type of situation doesn't 
> involve calling external Python scripts.
> 
> Maybe I can just try this also and see if it works, but I don't know the 
> code to use to write such an include statement. What would the 
> equivalent of this be in Python:
> 
> <?php include('file.html'); ?>
> 
> Thanks.

There are various ways you can do this, each of which depends on having 
a particular framework in place. Since your web service provider tells 
you that mod_python is available it's likely that you'll be able to use 
PSP (one of several beasts known as "Python Server Pages").

This is briefly described (for a flavor of the technology) in

   http://www.python.org/pycon/dc2004/papers/14/

by the author of mod_python. If you like what you see then take a look 
at the full mod_python documentation, at

   http://www.modpython.org/live/current/doc-html/

Note that purists might suggest this isn't the best way to use Python on 
the web. If it gets you where you want to be, feel free to ignore them :-)

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list