From d497c369e5ca20a1c96f0d597772c20ee3a19e5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=AE=A6=E6=88=90?= Date: Mon, 5 Oct 2015 18:27:40 +0800 Subject: [PATCH 1/2] Create 20151005 pyinfo() A good looking phpinfo-like python script.md --- ...good looking phpinfo-like python script.md | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 sources/tech/20151005 pyinfo() A good looking phpinfo-like python script.md diff --git a/sources/tech/20151005 pyinfo() A good looking phpinfo-like python script.md b/sources/tech/20151005 pyinfo() A good looking phpinfo-like python script.md new file mode 100644 index 0000000000..3f3e3291eb --- /dev/null +++ b/sources/tech/20151005 pyinfo() A good looking phpinfo-like python script.md @@ -0,0 +1,28 @@ +pyinfo() A good looking phpinfo-like python script +================================================================================ +Being a native php guy, I'm used to having phpinfo(), giving me easy access to php.ini settings and loaded modules etc. So ofcourse I wanted to call the not existing pyinfo() function, to no avail. My fingers quickly pressed CTRL-E to google for a implementation of it, someone must've ported it already? + +Yes, someone did. But oh my was it ugly. Preposterous! Since I cannot stand ugly layouts *cough*, I just had to build my own. So I used the code I found and cleaned up the layout to make it better. The official python website isnt that bad layout-wise, so why not steal their colors and background images? Yes that sounds like a plan to me. + +[Gits Here][1] | [Download here][2] | [Example here][3] + +Mind you, I only ran it on a python 2.6.4 server, so anything else is at your own risk (but it should be no problem to port it to any other version). To get it working, just import the file and call pyinfo() while catching the function's return value. Print that on the screen. Huzzah! + +For those who did not get that and are using [mod_wsgi][4], run it using something like this (replace that path ofcourse): +``` +def application(environ, start_response): + import sys + path = 'YOUR_WWW_ROOT_DIRECTORY' + if path not in sys.path: + sys.path.append(path) + from pyinfo import pyinfo + output = pyinfo() + start_response('200 OK', [('Content-type', 'text/html')]) + return [output] +``` + + +[1]:https://gist.github.com/951825#file_pyinfo.py +[2]:http://bran.name/dump/pyinfo.zip +[3]:http://bran.name/dump/pyinfo/index.py +[4]:http://code.google.com/p/modwsgi/ From 076267735349c81817e52da3c73a4397f1f66170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=AE=A6=E6=88=90?= Date: Mon, 5 Oct 2015 18:32:58 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=80=89=E9=A2=98=EF=BC=9Apyinfo()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 20151005 pyinfo() A good looking phpinfo-like python script --- ...o() A good looking phpinfo-like python script.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sources/tech/20151005 pyinfo() A good looking phpinfo-like python script.md b/sources/tech/20151005 pyinfo() A good looking phpinfo-like python script.md index 3f3e3291eb..7b38244e76 100644 --- a/sources/tech/20151005 pyinfo() A good looking phpinfo-like python script.md +++ b/sources/tech/20151005 pyinfo() A good looking phpinfo-like python script.md @@ -20,8 +20,19 @@ def application(environ, start_response): start_response('200 OK', [('Content-type', 'text/html')]) return [output] ``` - +--- +via:http://bran.name/articles/pyinfo-a-good-looking-phpinfo-like-python-script/ + +作者:[Bran van der Meer][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译, +[Linux中国](https://linux.cn/) 荣誉推出 + + +[a]:http://bran.name/resume/ [1]:https://gist.github.com/951825#file_pyinfo.py [2]:http://bran.name/dump/pyinfo.zip [3]:http://bran.name/dump/pyinfo/index.py