标签:style blog http color os 使用 io ar for
先编写hello.py
,实现Web应用程序的WSGI处理函数:
# hello.py def application(environ, start_response): start_response(‘200 OK‘, [(‘Content-Type‘, ‘text/html‘)]) return ‘<h1>Hello, %s!</h1>‘ % (environ[‘PATH_INFO‘][1:] or ‘web‘)
再编写一个server.py
,负责启动WSGI服务器,加载application()
函数:
from wsgiref.simple_server import make_server from hello import application httpd = make_server(‘‘, 8000, application) print "Serving HTTP on port 8000..." httpd.serve_forever()
标签:style blog http color os 使用 io ar for
原文地址:http://www.cnblogs.com/super-d2/p/3945857.html