-
-
Save NickNaso/79498b865b10c0f08d2f672c681addc8 to your computer and use it in GitHub Desktop.
WOWOW
This file contains hidden or 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
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