Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Nilesh Yadav
Added: Jan 27, 2018 6:09 AM
Modified: Jan 31, 2018 12:08 PM
Views: 38
Tags: nodejs
  1. const http = require('http');
  2.  
  3. const hostname = '127.0.0.1';
  4. const port = 3000;
  5.  
  6. const server = http.createServer((req, res) => {
  7.   res.statusCode = 200;
  8.   res.setHeader('Content-Type', 'text/plain');
  9.   res.end('Hello World\n');
  10. });
  11.  
  12. server.listen(port, hostname, () => {
  13.   console.log(`Server running at http://${hostname}:${port}/`);
  14. });