[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Apache + Pyhton



On Mon, Apr 15, 2002 at 10:51:07PM +0100, Miguel Ángel Vilela wrote:
> 
> Hola,  instalé  en  SID  el  paquete  liapache-mod-python,  descomenté
> la línea  "LoadModule python_module /usr/lib/apache/1.3/mod_python.so"
> en  /etc/apache/httpd.conf y  reinicié  el apache  (/etc/init.d/apache
> restart). Adicionalmente modifiqué el httpd.conf para poner:
> 
> <IfModule mod_dir.c>
>     DirectoryIndex index.php index.html index.htm index.shtml index.cgi index.py
> </IfModule>
> 
> Sin embargo,  no encuentro  la forma de  utilizar scripts  Python para
> generar páginas HTML  como con PHP. El síntoma es  que en el navegador
> (mozilla  0.9.9)  pongo http://127.0.0.1/index.py  y  lo  que hace  el
> navegador es  visualizar el fichero tal  como es, no se  ejecuta en el
> servidor. ¿Qué me falta por hacer?


Pido  disculpas  por   preguntar  algo  que  acabo   de  encontrar  en
/usr/share/doc/libapache-mod-python X) 

En realidad el rollo no parece tan sencillo como poner un index.py con
un simple  print "Hola mundo".  Hay que  añadir unas directivas  en el
httpd.conf para añadir  manejadores. En mi caso he probado  a poner al
final:

<Directory /home/httpd/html>
    AddHandler python-program .py
    PythonHandler index
</Directory>

Nota: /home/httpd/html  es el  path físico  del raíz  del web.  En ese
directorio está el script index.py que les adjunto. 

Gracias al par  de respuestas que recibí, tendré más  cuidado antes de
preguntar bobadas O:-)


-- 

        --==--   --==--   Miguel Ángel Vilela   --==--   --==--       

  a.k.a  miguev  at  fmat.ull.es,  GULiC,  Barrapunto &  IRC-Hispano  
  GULiC - Grupo de Usuarios Linux de Canarias - http://www.gulic.org  
  Facultad de Matemáticas, Universidad La Laguna --- www.fmat.ull.es  
  Public GPG key at http://search.keyserver.net (search for: miguev)  
  Linux Reg. User #184518 - Debian GNU/Linux SID - kernel 2.4.16-xfs 
  Linux Reg. Machines:  #81674,  #81677,  #105478,  #118020, #118022 
  -- Linux Driver Petition #73209 --- No ePatents Petition #80354 --  
 
 Your good nature will bring unbounded happiness. 

from mod_python import apache

def handler(req):
	req.content_type = "text/html"
	req.send_http_header()
	req.write("<center><input type=button value='¡Hola Mundo!'></center>")
	#req.write("<center><h1>(" + varchona + ")</h1></center>")
	return apache.OK

Attachment: pgpC_pbprbRbT.pgp
Description: PGP signature


Reply to: