python eve [Errno 32] Broken pipe... Ajax 呼叫的 WSGI
WSGI with python eve [Errno 32] Broken pipe... Ajax call
我是 运行 一个简单的 wsgi 服务器,
from run import app
if __name__ == "__main__":
app.run(threaded=True, debug=True)
我正在用获取请求访问服务器,服务器 return 是一条 200 消息,但 return 没有任何数据。我收到以下错误消息
Error on request:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/werkzeug/serving.py", line 209, in run_wsgi
execute(self.server.app)
File "/Library/Python/2.7/site-packages/werkzeug/serving.py", line 200, in execute
write(data)
File "/Library/Python/2.7/site-packages/werkzeug/serving.py", line 175, 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
我在一些地方读到过使用线程选项应该可以避免管道损坏错误,但似乎对我的情况没有帮助。有人有什么想法吗?
Flask 版本为 0.12.2。
!!!编辑!!!
所以我正在开发的页面的重点是从传单地图中获取用户定义的坐标并调用数据库,在本例中为 neo4j。查询工作正常, API 也是如此,因为它在邮递员中一切正常。所以问题一定出在我的网络应用程序中的某个地方。这是我的网页服务器应用程序。也许在 Ajax 通话中?
from flask import Flask, render_template
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
@app.route('/demo')
def webMap():
return render_template('demo3.html')
if __name__ == '__main__':
app.config['DEBUG'] = True
app.run(host='localhost', port=8090)
这是JS:
var map = L.map('map1').setView([51.506725, -0.076486], 12);
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
maxZoom: 18,
id: 'mapbox.streets',
accessToken: '*************************'
}).addTo(map);
//add start marker to map and delete old marker
var startmarker = null;
map.on('click', function (e) {
if (startmarker !== null) {
map.removeLayer(startmarker);
}
startmarker = L.marker(e.latlng, {
title: "Start Point",
}).addTo(map);
startcoords = e.latlng.lng.toString() + "&" + e.latlng.lat.toString();
startmarker.bindPopup("Start " + startcoords);
});
//add end marker to map and delete old marker
var endmarker = null;
map.on('contextmenu', function (e) {
if (endmarker !== null) {
map.removeLayer(endmarker);
}
endmarker = L.marker(e.latlng, {
title: "End Point",
}).addTo(map);
endcoords = e.latlng.lng.toString() + "&" + e.latlng.lat.toString();
endmarker.bindPopup("End " + endcoords);
coords = startcoords+"&"+endcoords;
});
// choose query type, click button & Ajax call to API server
$("#button").click(function() {
var val = $('input[name=query]:checked').val()
if (val == 'route') {
stuff = $.ajax({
url: "http://127.0.0.1:5000/route&"+coords,
type: "GET",
dataType: "json" ,
})
.done(function( json ) {
alert(JSON.stringify(stuff)); // trying to JSON back will work out how to display it after I get some data returned
})
.fail(function( xhr, status, errorThrown ) {
alert( "Sorry, there was a problem!");
console.log( "Error: " + errorThrown );
console.log( "Status: " + status );
console.dir( xhr );
})
.always(function( xhr, status ) {
alert( "The request is complete!" );
});
"The Broken pipe indicates that the other end of a socket or pipe that your flask process wants to talk to has died. Considering that you are interacting with the database it's very likely that the database has terminated the connection, or the connection has died for other reasons" ()
我是 运行 一个简单的 wsgi 服务器,
from run import app
if __name__ == "__main__":
app.run(threaded=True, debug=True)
我正在用获取请求访问服务器,服务器 return 是一条 200 消息,但 return 没有任何数据。我收到以下错误消息
Error on request:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/werkzeug/serving.py", line 209, in run_wsgi
execute(self.server.app)
File "/Library/Python/2.7/site-packages/werkzeug/serving.py", line 200, in execute
write(data)
File "/Library/Python/2.7/site-packages/werkzeug/serving.py", line 175, 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
我在一些地方读到过使用线程选项应该可以避免管道损坏错误,但似乎对我的情况没有帮助。有人有什么想法吗?
Flask 版本为 0.12.2。
!!!编辑!!!
所以我正在开发的页面的重点是从传单地图中获取用户定义的坐标并调用数据库,在本例中为 neo4j。查询工作正常, API 也是如此,因为它在邮递员中一切正常。所以问题一定出在我的网络应用程序中的某个地方。这是我的网页服务器应用程序。也许在 Ajax 通话中?
from flask import Flask, render_template
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
@app.route('/demo')
def webMap():
return render_template('demo3.html')
if __name__ == '__main__':
app.config['DEBUG'] = True
app.run(host='localhost', port=8090)
这是JS:
var map = L.map('map1').setView([51.506725, -0.076486], 12);
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
maxZoom: 18,
id: 'mapbox.streets',
accessToken: '*************************'
}).addTo(map);
//add start marker to map and delete old marker
var startmarker = null;
map.on('click', function (e) {
if (startmarker !== null) {
map.removeLayer(startmarker);
}
startmarker = L.marker(e.latlng, {
title: "Start Point",
}).addTo(map);
startcoords = e.latlng.lng.toString() + "&" + e.latlng.lat.toString();
startmarker.bindPopup("Start " + startcoords);
});
//add end marker to map and delete old marker
var endmarker = null;
map.on('contextmenu', function (e) {
if (endmarker !== null) {
map.removeLayer(endmarker);
}
endmarker = L.marker(e.latlng, {
title: "End Point",
}).addTo(map);
endcoords = e.latlng.lng.toString() + "&" + e.latlng.lat.toString();
endmarker.bindPopup("End " + endcoords);
coords = startcoords+"&"+endcoords;
});
// choose query type, click button & Ajax call to API server
$("#button").click(function() {
var val = $('input[name=query]:checked').val()
if (val == 'route') {
stuff = $.ajax({
url: "http://127.0.0.1:5000/route&"+coords,
type: "GET",
dataType: "json" ,
})
.done(function( json ) {
alert(JSON.stringify(stuff)); // trying to JSON back will work out how to display it after I get some data returned
})
.fail(function( xhr, status, errorThrown ) {
alert( "Sorry, there was a problem!");
console.log( "Error: " + errorThrown );
console.log( "Status: " + status );
console.dir( xhr );
})
.always(function( xhr, status ) {
alert( "The request is complete!" );
});
"The Broken pipe indicates that the other end of a socket or pipe that your flask process wants to talk to has died. Considering that you are interacting with the database it's very likely that the database has terminated the connection, or the connection has died for other reasons" (