Created
March 29, 2023 08:10
-
-
Save dsathyakumar/50592782a1c7ffb6f25a6b9df7460f01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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