Last active
August 29, 2015 14:03
-
-
Save chiehwen/6f791aa95c1a32a4e557 to your computer and use it in GitHub Desktop.
An example of a web server written with Node which responds with "Welcome to Node.js World."
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
| // server.js | |
| // Typing node server.js to turn on your Node server. | |
| // include the http module you need | |
| var http = require("http"); | |
| // access the createServer method in the http object | |
| http.createServer(function(request, response) { | |
| // tell the server what kind of file is coming at it | |
| response.writeHead(200, {"Content-Type": "text/plain"}); | |
| // make the server output a message | |
| response.write("Welcome to Node.js World."); | |
| // End the server interaction | |
| response.end(); | |
| }).listen(8888); // listening on port 8888 | |
| console.log('Server running at http://127.0.0.1:8888'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment