Emmanuel. M. Decarie
emm at scriptdigital.com
Thu Dec 28 12:07:38 EST 2000
Hello, I just tried the publisher handler with the "hello.py" example found in the manual: > >""" Publisher example """ > >def say(req, what="NOTHING"): > return "I am saying %s" % what http://www.modpython.org/live/mod_python-2.7.1/doc-html/hand-pub-intro.html Its working fine. But I didn't find a way to send some HTML. The publisher handler seems to always return "Content-Type: text/plain". How can I tell it to return "Content-Type: text/html". When I put at the top of the file "hello.py" this line: from mod_python import apache it look like that I can read the req object, but that I can't set values. For example, If I rewrite the hello.py example: from mod_python import apache def say(req, what="NOTHING"): req.content_type = "text/html" req.send_http_header () req.write (what) return apache.OK And then try to access /hello.py/say, Apache is not serving the page. I'm fairly new to Python, Apache and mod_python, so its a lot to swallow. I'm using FreeBSD 4.0 and mod_python 2.7.1 and Python 2.0. I like the way the publisher handler work, but I really need to have control on the HTTP headers returned by mod_python to be able to choose to publish plain text, html, or do redirection, send 404 code and so on. TIA Cheers -Emmanuel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Emmanuel Décarie - Consultant Programmation pour le Web - Programming for the Web UserLand Frontier - Perl - JavaScript - AppleScript - HTML - XML http://www.scriptdigital.com ---> The Frontier Newbie Toolbox: <http://www.scriptdigital.com/fnt/frontierNewbieToolbox.html>
|