WSGI 是一種接口規(guī)定,服務(wù)器程序 只有實(shí)現(xiàn)了這種接口規(guī)定,才能和應(yīng)用端程序(框架)很好的結(jié)合。
wsgiref就是一種服務(wù)端程序的一種,他在python3 里面內(nèi)嵌了。
服務(wù)端程序
- 規(guī)定:調(diào)用應(yīng)用端程序
- 應(yīng)用端處理邏輯概要:
def run(application):
environ = {}
def start_response(status, response_headers, exc_info=None):
pass
result = application(environ, start_response)
def write(data):
pass
for data in result:
write(data)
- 應(yīng)用端概要
def application(environ,start_response)
pass
- 調(diào)用概要
run(application)
wsgiref
wsgiref實(shí)現(xiàn)了上面 run的功能。wsgiref.simple_server 提供了相關(guān)的方法
參考
服務(wù)端程序:https://wsgi.readthedocs.io/en/latest/servers.html
wsgiref:https://docs.python.org/3.6/library/wsgiref.html#examples
environ-variables一覽:https://www.python.org/dev/peps/pep-0333/#environ-variables