如何访问mod_python目录中的根路径?
在我的Apache Web服务器中,我放置了以下内容:如何访问mod_python目录中的根路径?,python,mod-python,publisher,Python,Mod Python,Publisher,在我的Apache Web服务器中,我放置了以下内容: <Directory /var/www/MYDOMAIN.com/htdocs> SetHandler mod_python PythonHandler mod_python.publisher PythonDebug On </Directory> SetHandler mod_python PythonHandler mod_python.publisher 蟒蛇 然后我有一个带有索
<Directory /var/www/MYDOMAIN.com/htdocs>
SetHandler mod_python
PythonHandler mod_python.publisher
PythonDebug On
</Directory>
SetHandler mod_python
PythonHandler mod_python.publisher
蟒蛇
然后我有一个带有索引函数的handler.py文件
当我转到MYDOMAIN.com/handler.py时,我看到一个由index函数生成的网页(只是一个普通的HTML页面)。每隔一个页面都属于这种类型:MYDOMAIN.com/handler.py/somename,其中somename对应于handler.py文件中的函数
但当我访问MYDOMAIN.com时,我会发现:
找不到
在上找不到请求的URL/
这台服务器
mod_python和publisher是否有办法只使用根而不是name.py作为起点
我已经在apache conf文件中尝试过:
DirectoryIndex处理程序.py
无效:(尝试在目录中创建一个名为index(或其他)的空文件,然后使用
DirectoryIndex index
似乎DirectoryIndex检查是在监视文件系统时完成的。是的,但您需要创建自己的处理程序。您当前使用的是publisher,它只检查URI并加载给定的python模块 要创建自己的处理程序,您需要创建如下模块(只是一个简单的示例): 然后在Apache配置中指向它
您仍然可以在自己的处理程序中使用publisher处理程序,尽管您现在还不能拥有漂亮的URL。不要使用mod_python。它很糟糕。请改用mod_wsgi。
from mod_python import apache
def requesthandler(req):
req.content_type = "text/plain"
req.write("Hello World!")
return apache.OK