Chinaunix首页 | 论坛 | 博客
  • 博客访问: 757410
  • 博文数量: 26
  • 博客积分: 8255
  • 博客等级: 中将
  • 技术积分: 934
  • 用 户 组: 普通用户
  • 注册时间: 2006-02-06 01:52
文章分类

全部博文(26)

文章存档

2012年(1)

2011年(8)

2010年(10)

2008年(7)

分类: Python/Ruby

2010-03-12 11:21:13

版本 apache2.2 python 2.5.1 mod_python 3.3.1()

下载mod_python安装文件,安装后配置apache中 http.conf文件

(我的py文件存放目录是c:/pysys)

加载如下内容:

Alias /py c:/pysys/


Allow from all
AddHandler mod_python .prog
SetHandler mod_python
PythonHandler test
PythonDebug On

Order allow,deny
Deny from all



建立一个测试文件:


# mod_python test example - test.py
from mod_python import apache
from sys import version

def writeinfo(req,name,value):
    req.write("

%s
%s
\n" % (name,value))

def handler(req):
    req.content_type = "text/html"
    if req.header_only:
        return apache.OK

    req.write("""mod_python is work
    
    
    

mod_python is working


    You have successfully configutred mod_python on your Apache system.
    Here is some information about the environment and this request:
    


    


    """)

    writeinfo(req,"Client IP",req.get_remote_host(apache.REMOTE_NOLOOKUP))
    writeinfo(req,"URI",req.uri)
    writeinfo(req,"Filename",req.filename)
    writeinfo(req,"Canonical filename",req.canonical_filename)
    writeinfo(req,"Path_info",req.path_info)
    writeinfo(req,"Python version",version)

    req.write("
\n"
)

    return apache.OK


输入
阅读(3363) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~