[英]mod_python returns a blank screen
I'm trying to run mod_python.publisher in apache2. 我正在尝试在apache2中运行mod_python.publisher。 All I want to do is simply print "Hello World"
我只想简单地打印“ Hello World”
When I run my program, I get a blank screen. 运行程序时,出现黑屏。 My .py program looks like this:
我的.py程序如下所示:
def index():
print ("Hello World")
index()
However when I run the program: 但是,当我运行程序时:
def index(req):
print ("Hello World")
index()
I get this error message that says index() requires and argument and 0 is given: 我收到此错误消息,指出index()需要和参数,并且给出了0:
MOD_PYTHON ERROR
ProcessId: 23348
Interpreter: 'test.com'
ServerName: 'test.com'
DocumentRoot: '/var/www'
URI: '/modPythonTest.py'
Location: None
Directory: '/var/www/'
Filename: '/var/www/modPythonTest.py'
PathInfo: ''
Phase: 'PythonHandler'
Handler: 'mod_python.publisher'
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1229, in _process_target
result = _execute_target(config, req, object, arg)
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1128, in _execute_target
result = object(arg)
File "/usr/lib/python2.7/dist-packages/mod_python/publisher.py", line 204, in handler
module = page_cache[req]
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1059, in __getitem__
return import_module(req.filename)
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 296, in import_module
log, import_path)
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 680, in import_module
execfile(file, module.__dict__)
File "/var/www/modPythonTest.py", line 5, in <module>
index()
TypeError: index() takes exactly 1 argument (0 given)
So based on that, I looks like my code is being compiled. 因此,基于此,我似乎正在编译我的代码。 I get an error from bad code, but no output on good code.
我从错误的代码中得到了一个错误,但是在良好的代码上没有输出。 Any ideas?
有任何想法吗?
This ended up working for me: 最终为我工作:
#!/usr/bin/python
from mod_python import apache
def index(req):
out = "<html><head>"
out = out+"<meta http-equiv='content-type' content='text/html'></head>"
out = out+"<body>Hello World</body></html>"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.