2024-09-26 18:08:13 发布
网友
n00b问题。 我有一个.htaccess文件,其中包含以下内容:
AddHandler python-program .py PythonHandler index
我试图编写另一个名为script2.py的程序,但当我键入它fileserver/script2.py时,它会重定向到fileserver/index.py。有什么办法阻止这一切吗?
配置mod_python有不同的方法。我想你想要python.publisher。文档显示此配置:
AddHandler python-program .py PythonHandler mod_python.publisher
那么,对于您的示例,script2.py将具有如下内容:
def index(req): # Your handler here
注意,文件上说:
This handler allows access to functions and variables within a module via URL's.
文档提供了这个示例(我已将其更改为使用script2.py):
def say(req, what="NOTHING"): return "I am saying %s" % what
A URL http://www.mysite.com/script2.py/say would return "I am saying NOTHING". A URL http://www.mysite.com/hello.py/say?what=hello would return "I am saying hello".
通常您不想公开每个函数和变量。
The traversal will stop and HTTP_NOTFOUND will be returned to the client if:Any of the traversed object's names begin with an underscore ("_"). Use underscores to protect objects that should not be accessible from the web.
The traversal will stop and HTTP_NOTFOUND will be returned to the client if:
配置mod_python有不同的方法。我想你想要python.publisher。文档显示此配置:
那么,对于您的示例,script2.py将具有如下内容:
注意,文件上说:
文档提供了这个示例(我已将其更改为使用script2.py):
通常您不想公开每个函数和变量。
相关问题 更多 >
编程相关推荐