Skip to content

Instantly share code, notes, and snippets.

@dsathyakumar
Created March 29, 2023 08:04
Show Gist options
  • Save dsathyakumar/4cb445820ca12a177a384ca1435bf56b to your computer and use it in GitHub Desktop.
Save dsathyakumar/4cb445820ca12a177a384ca1435bf56b 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)
.on('error', function(err) {
// Something went wrong during writing
})
.on('end', function() {
// Value of output: "ABC"
});
out.write('A');
out.write('B');
out.write('C');
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