WSGI servers-wsgiref

WSGI 是一种接口规定,服务器程序 只有实现了这种接口规定,才能和应用端程序(框架)很好的结合。
wsgiref就是一种服务端程序的一种,他在python3 里面内嵌了。

服务端程序

  • 规定:调用应用端程序
  • 应用端处理逻辑概要:
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)
  • 应用端概要
def application(environ,start_response)
      pass
  • 调用概要
run(application)

wsgiref

wsgiref实现了上面 run的功能。wsgiref.simple_server 提供了相关的方法

参考

服务端程序: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

你可能感兴趣的:(WSGI servers-wsgiref)