python-wsgi测试服务器

1 #!/usr/bin/python
2 from wsgiref.simple_server import make_server
3 def application(environ,start_response):
4     start_response('200 ok',[('Content-Type','text/html')])
5     return '<h1>hello %s</h1>'%(environ['PATH_INFO'][1:] or 'web')
6 
7 httpd=make_server('',8080,application)
8 print "Serving HTTPon port 8080..."
9 httpd.serve_forever()

直接运行代码,浏览器输入 localhost:端口号  即可看到效果。

原文地址:https://www.cnblogs.com/chengyunshen/p/7196198.html