第一个Quixote APP跑起来!

其实只是把Demo挪了一个位置,让Apache指向这里。

Quixote自带了Quixote。希望以此为模板开发自己的第一个Quixote App。步骤如下:

1.建立目录D:/do/maqi.就把do当作自己的工作目录。包的名字叫做maqi,以免与quixote的命名空间冲突
2.将quixote/demo目录拷贝到d:/do/maqi,这样demo的位置是d:/do/maqi/demo
3.增加环境变量PythonPATH=d:/do
4.打开d:/do/maqi/demo/__init__.py,修改如下:
from quixote import enable_ptl
from quixote.publish import Publisher
enable_ptl()

def create_publisher():
#在这里更改包名
#    from quixote.demo.root import RootDirectory
    from maqi.demo.root import RootDirectory
    return Publisher(RootDirectory(), display_exceptions='plain')

5.修改Apache的httpd.conf
设置文档根目录。注意用/
DocumentRoot "D:/"

LoadModule python_module  modules/mod_python.so

#这里我偷懒了,直接用do目录
<Directory "D:/do/">
        #AddHandler mod_python .py
        #PythonHandler mptest
        #PythonHandler mod_python.publisher
        #PythonHandler   demo
        #PythonDebug On
       
#        AuthType Basic
#      AuthName "Restricted Area"
#      require valid-user
        SetHandler python-program
        #PythonHandler quixote.server.mod_python_handler
        PythonHandler maqi.server.mod_python_handler
        #PythonOption quixote-publisher-factory quixote.demo.create_publisher
        PythonOption quixote-publisher-factory maqi.demo.create_publisher
        #PythonInterpreter quixote.demo
        PythonInterpreter maqi.demo
        PythonDebug On
</Directory>

6.重启Apache.
7.访问:http://localhost:8080/do/a.py
注意,其实这里并没有一个叫做a.py的文件。只是该Directory设置用mod_py响应.py文件而已。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值