|
Jorey Bump
list at joreybump.com
Sun Jul 2 15:05:15 EDT 2006
Diogo Pitz wrote:
> I've put this lines in my .conf apache file:
>
> <Directory "C:\arquivos_diogo\python">
> AddHandler mod_python .py
> PythonHandler Script1
> PythonDebug On
> </Directory>
Delete that.
> <Directory "C:\arquivos_diogo\python">
> AddHandler mod_python .py
> PythonHandler mod_python.publisher
> PythonDebug On
> </Directory>
OK.
> with this I have my codes working, but not in the way I want.
> I have a .py file called helloworld.py, and this is its code:
>
> from mod_python import apache
>
> def handler(req):
> req.content_type = 'text/plain'
> req.write("Hello World!")
> return apache.OK
Delete all of that and replace it with this:
def index():
return "Hello, World!"
> to see "Hello World" in my browser, I have to type
> http://localhost/python/helloworld.py/handler .
With the new settings, you can access it in the following ways:
http://host/python/helloworld.py/
http://host/python/helloworld.py/index
mod_python.publisher must point to a function within your module, unless
there is an index() function.
> and one more question, can I write a html file in python, like this?
>
> print "<html><body><p>something</p></body></html>"
If you use Publisher, you can just construct an HTML page as a string
and return it from your function. Publisher will do the rest.
> or mod_python doesn't allow me to make this? if it doesn't, what
> solution can be used to do it?
Read the manual and try to understand Publisher a bit. If it doesn't fit
your needs, explore writing your own handler.
|