mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-03 23:40:14 +08:00
commit
c84cd2babd
@ -1,40 +0,0 @@
|
||||
translation by strugglingyouth
|
||||
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]
|
||||
```
|
||||
---
|
||||
|
||||
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
|
||||
[4]:http://code.google.com/p/modwsgi/
|
@ -0,0 +1,40 @@
|
||||
pyinfo()一个像 phpinfo 一样的 Python 脚本
|
||||
================================================================================
|
||||
作为一个热衷于 php 的家伙,我已经习惯了使用 phpinfo() 函数来让我轻松访问 php.ini 里的配置和加载的模块等。当然我也想要使用一个不存在的 pyinfo() 函数,但没有成功。在 google 中按下 CTRL-E 快速查找是否有人实现了它?
|
||||
|
||||
是的,有人已经实现了。但是,对我来说它非常难看。荒谬!因为我无法忍受丑陋的布局 *咳嗽*,我不得不亲自动手来做。所以我用找到的代码,并重新进行布局使之更好看点。Python 官方网站的布局看起来不错,那么何不盗取他们的颜色和背景图片呢?是的,这听起来像一个计划。
|
||||
|
||||
[Gits Here][1] | [Download here][2] | [Example here][3]
|
||||
|
||||
提醒你下,我仅仅在 Python 2.6.4 上运行过它,所以在别的版本上可能有风险(将它移植到任何其他版本它应该是没有问题的)。为了能使它工作,只需要导入 pyinfo() 文件,并将函数的返回值打印到屏幕上。好嘞!
|
||||
|
||||
如果你没有得到正确的返回结果,你需要使用 [mod_wsgi][4],然后这样运行它(当然得替换路径):
|
||||
|
||||
```
|
||||
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]
|
||||
```
|
||||
---
|
||||
|
||||
via:http://bran.name/articles/pyinfo-a-good-looking-phpinfo-like-python-script/
|
||||
|
||||
作者:[Bran van der Meer][a]
|
||||
译者:[strugglingyouth](https://github.com/strugglingyouth)
|
||||
校对:[校对者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
|
||||
[4]:http://code.google.com/p/modwsgi/
|
Loading…
Reference in New Issue
Block a user