[mod_python] How do I serve up .html files?

Kirk Bailey idiot1 at netzero.net
Mon Aug 25 22:42:06 EST 2003


When a browser accesses a html page, one includes a SSI exec tag. That means 
Server Side Include, exec(ute).

It looks like a comment, and if it made it to the browser, it would be treated 
as such and therefore invisible. But if all is done right, it is EATEN by the 
webserver and replaced with the output of the script.

<!--#exec cgi="./cgi-bin/counter.py" -->

Is probably the most common example of a ssi tag in a webpage. If you never use 
any other ssi, you will use that one. The example above would run some sort of a 
counter program (such as my 'counter.py'), returning a string of text. This is a 
string of characters, such as numbers:
32204
which is the output of a text counter program.

I am not going to describe how to enable cgi on apache, or any other webserver- 
that's a booklet worth, not a letter's. BUT my website has articles on cgi on 
it, and links to entire SITES about it, including apache.org's pages about ssi 
and apache. The ssi stuff is at the bottom of the homepage.

	http://www.tinylist.org/

hope this helps.


Gregory (Grisha) Trubetskoy wrote:

> On Mon, 25 Aug 2003, Russell Nelson wrote:
> 
> 
>>Maybe this is really an Apache question, but it seems to me like it
>>ought to come up in a mod_python context as well.  Can't find it in
>>the documentation, the FAQ, or the mailing list archives
>>(Aug/Jul/Jun).
>>
>>How do I cause my python script to be run when a .html file is accessed?
>>    http://angry-economics.russnelson.com/index.html
> 
> 
> Russell -
> 
> It is pretty much an apache question.
> 
>   AddHandler python-program .html
>   PythonHandler myhandler
>   PythonDebug On
> 
> should do it (AddHandler is key, the other two are shown for completness).
> 
> 
>>How do I cause my python script to be run when any old file is accessed?
>>    http://angry-economics.russnelson.com/
> 
> 
>   SetHandler python-program
>   PythonHandler myhandler
>   PythonDebug On
> 
> would make every request be handled by mod_python, regardless of
> extension.
> 
> Of course the consequence of either of the above is that the mod_python
> handler would either need to actually do the work of delivering the HTML
> itself (the next version will have req.sendfile() to make it a bit more
> efficient), or return apache.DECLINED to let Apache handle it after mp
> handler did its thing (in which case the mp handler shouldn't write
> anything).
> 
> 
>>In other words, I want a handler which gets run no matter what the
>>rest of the URL is.  You'd think this would be in the documentation,
>>enabling people to make fully scripted sites, but it seems not to be.
> 
> 
> Here is one place where it's mentioned:
> 
> http://www.modpython.org/live/current/doc-html/tut-what-it-do.html
> 
> ...but I admit, the docs are written in a way as to not overlap Apache
> docs, which makes it difficult.
> 
> 
>>I can't insert a /foo.py/ in there because I have to preserve all the
>>old URLs.
> 
> 
> P.S. Glad to see you using mod_python!
> 
> Grisha
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
> 
> 

-- 

-- 

end

Cheers!
         Kirk D Bailey

  +                              think                                +
   http://www.howlermonkey.net  +-----+        http://www.tinylist.org
   http://www.listville.net     | BOX |  http://www.sacredelectron.org
   Thou art free"-ERIS          +-----+     'Got a light?'-Promethieus
  +                              think                                +

Fnord.



More information about the Mod_python mailing list