Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dsathyakumar/50592782a1c7ffb6f25a6b9df7460f01 to your computer and use it in GitHub Desktop.
Save dsathyakumar/50592782a1c7ffb6f25a6b9df7460f01 to your computer and use it in GitHub Desktop.
require('marko/node-require').install();
const http = require('http');
const server = require('http').createServer();
const port = 8080;
server.on('request', (req, res) => {
var out = require('async-writer').create(res);
out.write('A');
var asyncOut = out.beginAsync();
setTimeout(function() {
asyncOut.write('B');
}, 1000);
out.write('C');
setTimeout(function() {
asyncOut.write('D');
asyncOut.end();
}, 4000);
out.end();
});
server.listen(port, () => {
console.log(`Successfully started server on port ${port}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment