#!/usr/bin/python
from wsgiref.simple_server import make_server
def application(environ,start_response):
start_response('200 ok',[('Content-Type','text/html')])
return '<h1>hello %s</h1>'%(environ['PATH_INFO'][1:] or 'web') httpd=make_server('',8080,application)
print "Serving HTTPon port 8080..."
httpd.serve_forever()
直接运行代码,浏览器输入 localhost:端口号 即可看到效果。