WSGI=Web server getaway interface 服务器网关接口,常用第三方库gunicorn做代理。
HTTP请求:浏览器----->WSGI-------->django架构应用、
HTTP响应:django架构应用---->WSGI------->浏览器
WSGI使用理解:
linux centos7下执行
pip3 install gunicorn (安装gunicorn,windows下不支持可以安装但不能运行)
gunicorn app:simple_app (app是.py文件,simple_app是该.py文件下的一个函数)
simple_app需要做的事情(wsgi的回调函数):
有两个参数:
environ:环境变量,暂时不知道具体作用
start_response:回调函数-wsgi实现,需要设置head信息(前端html下有head/body两部分信息),
start_response(status,response_headers)
status=''200 ok" 状态信息
response_headers=['Content-type','text/plain'] 信息头
最会函数返回body部分信息