Skip to content

Instantly share code, notes, and snippets.

@NickNaso
Forked from MylesBorins/do-this-instead.js
Created January 29, 2020 06:03
Show Gist options
  • Save NickNaso/79498b865b10c0f08d2f672c681addc8 to your computer and use it in GitHub Desktop.
Save NickNaso/79498b865b10c0f08d2f672c681addc8 to your computer and use it in GitHub Desktop.
WOWOW
const {createServer} = require('http');
const {promisify} = require('util')
const hostname = '127.0.0.1';
const port = 3000;
const server = createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World');
});
const serverOn = promisify(server.on).bind(server);
async function main() {
server.listen(port, hostname);
await server.on('listening');
console.log(`Server running at http://${hostname}:${port}/`);
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment