nginx, flask, wsgi
原来自己还没搞懂这些。
首先post一个观点:
nginx应该是没解析任何东西,就判断是不是http请求,然后转发?或者判断是不是tcp请求,然后转发。
所以给了python后台就可以用wsgi解包。
浏览器发送一个HTTP请求;
服务器收到请求,生成一个HTML文档;
服务器把HTML文档作为HTTP响应的Body发送给浏览器;
浏览器收到HTTP响应,从HTTP Body取出HTML文档并显示。
flask默认实现了多线程啊。
在api里面print("??"), time.sleep(5)就知道了,先输出两个??
那
threaded=True,
processes=5,
这两个参数是干嘛的。
对,默认多线程,threaded=False,就可以开启不是多线程
GET
浏览器直接访问:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
GET / HTTP/1.1 Host: localhost:8888 Connection: keep-alive Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 Accept-Encoding: gzip, deflate, br Accept-Language: zh-CN,zh;q=0.9,en;q=0.8 Cookie: session=eyJ1c2VyX2lkIjoxMX0.XFBI2g.Y6DEEvE55BrKN1RAi3ahzr2ACLY
curl:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
('127.0.0.1', 37574)上线 GET / HTTP/1.1 Host: localhost:8888 User-Agent: curl/7.47.0 Accept: */*
nginx:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
GET / HTTP/1.0 Host: localhost:8080 X-Real-IP: 192.18.0.1 X-Forwarded-For: 192.18.0.1 Connection: close Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 Accept-Encoding: gzip, deflate, br Accept-Language: zh-CN,zh;q=0.9,en;q=0.8 Cookie: session=eyJ1c2VyX2lkIjoxMX0.XFBI2g.Y6DEEvE55BrKN1RAi3ahzr2ACLY If-None-Match: W/"5c334609-97a" If-Modified-Since: Mon, 07 Jan 2019 12:28:57 GMT
post man
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
GET / HTTP/1.1 Host: localhost:8888 Connection: keep-alive Cache-Control: no-cache User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36 Postman-Token: 30cd6141-94c1-72f4-867b-6812798e630d Accept: */* Accept-Encoding: gzip, deflate, br Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
curl post
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
('192.18.0.1', 37324)上线 POST / HTTP/1.1 Host: localhost:8888 User-Agent: curl/7.47.0 Accept: */* Content-Length: 144 Expect: 100-continue Content-Type: multipart/form-data; boundary=------------------------a2d7d2c79637d3d8 --------------------------a2d7d2c79637d3d8 Content-Disposition: form-data; name="weiming" aa --------------------------a2d7d2c79637d3d8--
postman post
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
('192.18.0.1', 37878)上线 POST / HTTP/1.1 Host: localhost:8888 Connection: keep-alive Content-Length: 141 User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36 Cache-Control: no-cache Origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop Postman-Token: 70ba296b-ceaa-10be-0fa0-99f50f7b92c3 Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryxQsGCT1GJEFAARPd Accept: */* Accept-Encoding: gzip, deflate, br Accept-Language: zh-CN,zh;q=0.9,en;q=0.8 ------WebKitFormBoundaryxQsGCT1GJEFAARPd Content-Disposition: form-data; name="weiming" liu ------WebKitFormBoundaryxQsGCT1GJEFAARPd--
postman post nginx
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
('192.18.0.6', 34046)上线 POST / HTTP/1.0 Host: localhost:8080 X-Real-IP: 192.18.0.1 X-Forwarded-For: 192.18.0.1 Connection: close Content-Length: 234 User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36 Cache-Control: no-cache Origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop Postman-Token: 63158aa1-955c-b6bf-0a25-3ddcf7db86df Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryNM8OhUBY87wBspdZ Accept: */* Accept-Encoding: gzip, deflate, br Accept-Language: zh-CN,zh;q=0.9,en;q=0.8 ------WebKitFormBoundaryNM8OhUBY87wBspdZ Content-Disposition: form-data; name="weiming" liu ------WebKitFormBoundaryNM8OhUBY87wBspdZ Content-Disposition: form-data; name="aaa" bbb ------WebKitFormBoundaryNM8OhUBY87wBspdZ--
既然选择了远方,就要风雨兼程~
posted on 2019-01-29 17:41 stupid_one 阅读(258) 评论(0) 编辑 收藏 举报