Last active
July 28, 2016 09:45
-
-
Save BasanthVerma/f02481ebbd5e392016d75933238972c2 to your computer and use it in GitHub Desktop.
Simplest node.js Server. Paste this in a file with .js extension and run it from Command line "node <fileName>.js"
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 http = require('http'); | |
| const hostname = '127.0.0.1'; | |
| const port = 3000; | |
| const server = http.createServer((req, res) => { | |
| res.statusCode = 200; | |
| res.setHeader('Content-Type', 'text/html'); | |
| res.end('Hello, from Node js\n'); | |
| }); | |
| server.listen(port, hostname, () => { | |
| console.log(`Server running at http://${hostname}:${port}/`); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment