WSGI的理解
WSGI(Web Server Gateway Interface)是描述Python应用和服务器之间标准接口的协议。若应用开发者和服务器开发者都实现这个协议,则双方都只需要专注自己所需要开发的功能,而不用考虑应用/服务器兼容的问题。 目前WSGI协议已经得到广泛实现, WSGI应用/框架有flask, django等,WSGI服务器有uWSGI(其实现的uwsgi协议是传输协议,主要用于与反向代理的通信), gunicorn等。 WSGI在PEP333中发布,主要内容为1: WSGI application are callable python objects (functions or classes with a call method that are passed two arguments: a WSGI environment as first argument and a function that starts the response. the application has to start a response using the function provided and return an iterable > where each yielded item means writing and flushing. The WSGI environment is like a CGI environment just with some additional keys that are either provided by the server or a middleware....