Flask框架,项目是前后分离。请求为fetch,后端post拿不到数据;具体症状:1.get可以获取,post请求发出后请求被挂起,页面没有响应;2.只要后端代码出现request.form就会出现被挂起3.搜索网上和segmentfault的写法,均无效;4.请求是POSTFormdatausername:'aaa'password:'11221212'后端代码@app.route('/blog/login',methods=['post'])deflogin():try:print(334,request.method,request.form.get('username'))except:print(11111)return'123'错误信息Traceback(mostrecentcalllast):File"/Users/zhongwangsheng/Developer/PyProject/family/venv/lib/python2.7/site-packages/werkzeug/serving.py",line270,inrun_wsgiexecute(self.server.app)File"/Users/zhongwangsheng/Developer/PyProject/family/venv/lib/python2.7/site-packages/werkzeug/serving.py",line261,inexecutewrite(data)File"/Users/zhongwangsheng/Developer/PyProject/family/venv/lib/python2.7/site-packages/werkzeug/serving.py",line236,inwriteself.send_header('Server',self.version_string())File"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/BaseHTTPServer.py",line401,insend_headerself.wfile.write("%s:%s\r\n"%(keyword,value))IOError:[Errno32]Brokenpipe以下为修改后的登录代码,还是一样的错误“请求被挂起,没反应,约1分钟后失败error”@app.route('/blog/login',methods=['post'])deflogin():try:print(111,request.data)print(222,request.form)except:print(333)return1234以下是用fetch发送的请求信息RequestURL:http://localhost:8084/blog/loginReferrerPolicy:no-referrer-when-downgradeProvisionalheadersareshownAuthorization:Content-Type:application/x-www-form-urlencodedOrigin:http://localhost:8084Referer:http://localhost:8084/User-Agent:Mozilla/5.0(Macintosh;IntelMacOSX10_13_3)AppleWebKit/537.36(KHTML,likeGecko)Chrome/64.0.3282.186Safari/537.36OPR/51.0.2830.55(EditionBaidu)FormDatapassword:123456username:zws
GCT1015
相关分类