我对这种行为感到非常困惑。
signUpForm() {
this.$http.post('http://localhost:5000/signup_d4d', {user: this.user}).then(response => {
// get body data
this.success = response.body;
alert('success');
}, response => {
// error callback
});
}
后端代码:
@app.route('/signup_d4d', methods=['POST'])
@cross_origin()
def sign_up_d4d():
form_data = json.loads(request.data)
print(form_data)
print('LOL')
return jsonify({}), 200
请求甚至没有跨越到python后端。
signUpForm() {
this.$http.post("http://localhost:5000/signup_d4d", {user: this.user},{headers: {'Accept': 'application/json'}});
alert('Created!');
}
这会发送请求,但会导致python flask框架在返回时抛出错误:
127.0.0.1 - - [12/Nov/2017 14:54:26] "POST /signup_d4d HTTP/1.1" 500 -
Error on request:
Traceback (most recent call last):
File "/Users/jayanthvenkatraj/git_repos/ihie/ihie_backend/ihie-resource-server/some/lib/python2.7/site-packages/werkzeug/serving.py", line 209, in run_wsgi
execute(self.server.app)
File "/Users/jayanthvenkatraj/git_repos/ihie/ihie_backend/ihie-resource-server/some/lib/python2.7/site-packages/werkzeug/serving.py", line 200, in execute
write(data)
File "/Users/jayanthvenkatraj/git_repos/ihie/ihie_backend/ihie-resource-server/some/lib/python2.7/site-packages/werkzeug/serving.py", line 181, in write
self.wfile.write(data)
IOError: [Errno 32] Broken pipe
如果有人将vuejs的工作样本发布到烧瓶后端,那将非常有用