Skip to content

Instantly share code, notes, and snippets.

@nishinoshake
Last active May 29, 2016 04:53
Show Gist options
  • Save nishinoshake/1d9df8f81270f49bbd1a to your computer and use it in GitHub Desktop.
Save nishinoshake/1d9df8f81270f49bbd1a to your computer and use it in GitHub Desktop.
Node.jsでPOSTデータを使う
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.post('/send/', function(req, res){
var s1 = req.body.s1 ? req.body.s1: 0,
s2 = req.body.s2 ? req.body.s2: 0,
s3 = req.body.s3 ? req.body.s3: 0;
io.sockets.emit('socket_sensor', [s1, s2, s3]);
res.send('OK');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment