Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80542 views
1
var http = require('http');
2
var ecstatic = require('ecstatic')(__dirname);
3
var server = http.createServer(function (req, res) {
4
if (req.method === 'POST' && req.url === '/plusone') {
5
res.setHeader('content-type', 'text/plain');
6
7
var s = '';
8
req.on('data', function (buf) { s += buf.toString() });
9
10
req.on('end', function () {
11
var n = parseInt(s) + 1;
12
res.end(n.toString());
13
});
14
}
15
else ecstatic(req, res);
16
});
17
18
console.log('Listening on :8082');
19
server.listen(8082);
20
21