Heroku Deployment - cindyweiss/seattle-301d55 GitHub Wiki

STEP BY STEP INSTRUCTIONS

First of all, we need to create a JavaScript file. Let's name it server.js:

in terminal: server.js var http = require("http");

http.createServer(function(request, response) { response.writeHead(200, {"Content-Type": "text/plain"}); response.write("It's alive!"); response.end(); }).listen(3000);

It's simple. It's tiny. But it's a server! Let's make sure it's working. Run at your terminal:

in terminal: node server.js

Then check it in your browser. Your new server's address, as you may guess, is http://localhost:3000/ Mine is working. How about yours? Hope, it's working too.

Now, to be sure it's a web server and not just a piece of code that returns a single line of text, we'll use it as a server! You can check it with your smartphone. Let's suppose, your laptop's IP address within your local network is 192.168.1.101. You can connect to your server through the 3000th port (for this particular example) by typing http://192.168.1.101:3000/ in your browser. Works well in my case: