Last active
December 30, 2016 21:17
-
-
Save lvidal1/83c67321390a66e3b79d040846547736 to your computer and use it in GitHub Desktop.
Setup a basic node-server
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
/* Previous Considerations | |
* ------------------------------- */ | |
//a. It is necessary nodejs must be installed on pc/linux or mac. | |
//b. This server runs on 127.0.0.1:8081. You can access : | |
// - by console with '$ node main.js' | |
// - by browser by goint to http://127.0.0.1:8081/ | |
/* The very basic server | |
* -------------------------------*/ | |
// 1. Import required modules | |
var http = require("http"); | |
// 2. Create a server | |
http.createServer(function(request,response){ | |
// Send the HTTP header | |
response.writeHead(200,{'Content-Type':'text/plain'}); | |
// Send the response body as "Hello World" | |
response.end('Hello World\n'); | |
}).listen(8081); | |
console.log('Server Running at http://127.0.0.1:8081'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment