You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
558 B
JavaScript
20 lines
558 B
JavaScript
7 years ago
|
var http = require('http');
|
||
|
var ecstatic = require('ecstatic')(__dirname);
|
||
|
var server = http.createServer(function (req, res) {
|
||
|
if (req.method === 'POST' && req.url === '/plusone') {
|
||
|
res.setHeader('content-type', 'text/plain');
|
||
|
|
||
|
var s = '';
|
||
|
req.on('data', function (buf) { s += buf.toString() });
|
||
|
|
||
|
req.on('end', function () {
|
||
|
var n = parseInt(s) + 1;
|
||
|
res.end(n.toString());
|
||
|
});
|
||
|
}
|
||
|
else ecstatic(req, res);
|
||
|
});
|
||
|
|
||
|
console.log('Listening on :8082');
|
||
|
server.listen(8082);
|