我的 Python 脚本,带有以下行:
from requests import post
...
while(1):
result = readSensors().result
payload["z"] = (result['zforce'])
payload["x"] = (result['xforce'])
payload["y"] = (result['yforce'])
payload["light"] = (result['light'] )
payload["pitch"] = ( result["pitch"] )
payload["azimuth"] = ( result["azimuth"] )
payload["roll"] = ( result["roll"] )
post(SERVER, data = payload )
sleep(0.02)
到我的 Heroku webapp 服务器会导致 Python 错误httplib.IncompleteRead: IncompleteRead(0 bytes read)
错误。
该web.js
文件如下所示:
var server = http.createServer(function(request, response){
if (request.method == 'POST'){
var body = '';
request.on('data', function (data) {
body += data;
});
request.on('end', function () {
//send data to clients.
io.sockets.emit( 'data', parse(body) );
});
response.end()
}
server.listen(process.env.PORT || 5000);
var io = io.listen(server);
io.set('log level', 1);
io.configure(function () {
io.set("transports", ["xhr-polling"]);
io.set("polling duration", 10);
});