Flask framework, items are separated before and after . Cannot get data for fetch, backend post;
specific symptoms:
1. getpost;
2. request.form
3. segmentfault;
4.
POST
Formdata
username: "aaa"
password: "11221212"
backend code
@app.route("/blog/login", methods=["post"])
def login():
try:
print(334,request.method, request.form.get("username"))
except:
print(11111)
return "123"
error message
Traceback (most recent call last):
File "/Users/zhongwangsheng/Developer/PyProject/family/venv/lib/python2.7/site-packages/werkzeug/serving.py", line 270, in run_wsgi
execute(self.server.app)
File "/Users/zhongwangsheng/Developer/PyProject/family/venv/lib/python2.7/site-packages/werkzeug/serving.py", line 261, in execute
write(data)
File "/Users/zhongwangsheng/Developer/PyProject/family/venv/lib/python2.7/site-packages/werkzeug/serving.py", line 236, in write
self.send_header("Server", self.version_string())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/BaseHTTPServer.py", line 401, in send_header
self.wfile.write("%s: %s\r\n" % (keyword, value))
IOError: [Errno 32] Broken pipe
the following is the modified login code, the same error "request was suspended, no response, about 1 minute later failed error"
@app.route("/blog/login", methods=["post"])
def login():
try:
print(111, request.data)
print(222, request.form)
except:
print(333)
return 1234
the following is the request information sent with fetch
Request URL:http://localhost:8084/blog/login
Referrer Policy:no-referrer-when-downgrade
Provisional headers are shown
Authorization:
Content-Type:application/x-www-form-urlencoded
Origin:http://localhost:8084
Referer:http://localhost:8084/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36 OPR/51.0.2830.55 (Edition Baidu)
Form Data
password:123456
username:zws