.htaccess with python scripts
1 answer
There are various ways to customize mod_python. I think you want python.publisher . The docs show this configuration:
AddHandler python-program .py
PythonHandler mod_python.publisher
Then for your example, script2.py would have something like:
def index(req):
# Your handler here
Please note: the documentation says:
This handler allows you to access functions and variables within a module via a URL.
The documentation provides this example (which I modified to use script2.py):
def say(req, what="NOTHING"):
return "I am saying %s" % what
The URL http://www.mysite.com/script2.py/say will return "I say NOTHING". The URL http://www.mysite.com/hello.py/say?what=hello will return "I say hi".
You usually don't want to expose every function and variable.
The traversal will stop and HTTP_NOTFOUND will be returned to the client if:
- Any of the named objects begins with an underscore ("_"). Use underscores to protect objects that should not be accessible from the Internet.
+3
source to share