python 最简单的 cgi webserver

在mkdir -p cgi/cgi-bin下面新建time.py

#!/usr/bin/env python
# -*- coding utf8 -*- 
import cgitb
cgitb.enable()
import time
print "Content-type: text/html" 
print 
print time.strftime('%Y-%m-%d %X', time.localtime() )

 

cgi 服务器建立
cd cgi
python -m CGIHTTPServer

到 firefox 中
http://127.0.0.1:8000/cgi-bin/time.py

posted @ 2013-04-04 18:40  Me.thinking  阅读(358)  评论(1编辑  收藏  举报