mod_python
有一個測試頁腳本,它發出有關服務器配置的信息。你可以把mod_wsgi的測試頁面
SetHandler mod_python
PythonHandler mod_python.testhandler
到您的.htaccess
,它顯示的頁面。
現在我的問題:mod_wsgi
也有類似的情況嗎?
mod_python
有一個測試頁腳本,它發出有關服務器配置的信息。你可以把mod_wsgi的測試頁面
SetHandler mod_python
PythonHandler mod_python.testhandler
到您的.htaccess
,它顯示的頁面。
現在我的問題:mod_wsgi
也有類似的情況嗎?
號你可以創造一些的那種樂於助人的迭代環保,無毒的鑰匙,雖然:
def application(env, respond):
respond('200 OK', [('Content-Type', 'text/plain')])
return ['\n'.join('%s: %s' % (k, v) for (k, v) in env.iteritems())]
謝謝你的回答。同時我也找到了這樣的解決方案,但我希望有更廣泛的東西。 'mod_python'測試站點提供了其他信息,例如有關服務器及其配置的一般信息。但環境是一個非常好的開始。 – glglgl 2013-02-25 19:24:54
我現在已經放在一起就像一個測試頁面在這裏。爲了您的方便,我會在這裏與您分享:
def tag(t, **k):
kk = ''.join(' %s=%r' % kv for kv in k.items())
format = '<%s%s>%%s</%s>' % (t, kk, t)
return lambda content: format % content
def table(d):
from cgi import escape
escq = lambda s: escape(s, quote=True)
tr = tag('tr')
th = tag('th')
td_code = lambda content: tag('td')(tag('code')(content))
return tag('table', border='1')(''.join((
'\n\t' + tr(th('Key') + th('Value') + th('Repr')) + '\n',
''.join(('\t' + tr(td_code('%s') + td_code('%s') + td_code('%s')) + '\n') % (k, escq(str(v)), escq(repr(v))) for k, v in sorted(d.items())),
))) + '\n'
def application(environ, start_response):
import os
l = []
from wsgiref.headers import Headers
h = Headers(l)
h.add_header('Content-Type', 'text/html')
start_response('200 OK', l)
yield '<html><head><title>my mod_wsgi test page</title></head><body>\n'
# yield '<h3>General information</h3>\n'
# yield table({})
yield '<h3>Process info</h3>\n'
yield table(dict(
wd=os.getcwd(),
pid=os.getpid(),
ppid=os.getppid(),
uid=os.getuid(),
gid=os.getgid(),
))
yield '<h3>Environment</h3>\n'
yield table(environ)
A downvote and no comment。謝謝。 – glglgl 2013-11-20 21:20:56