Manufacturer
node.js
Product Website
URL Screenshot of http://nodejs.org
Price
Free/Open Source
Pros
You get to use the JavaScript in both the client side and server side.
Cons
By itself, you have to write an entire web server (but there are additional libraries that handle that)
Summary
node.js may well be the next big thing in web application development, as it allows you to write server-side code in the same language you use for writing client/browser-side code, JavaScript.
Rating
9/10
6

. Some more HTML follows, and then the original requested URL gets written out, mainly as a demonstration.

The original call to createServer returns a server object, and then we call that object's listen method, which you can see in the line second from last. This call says to listen on address 127.0.0.1 via port 8124. (Normally web servers use port 80; I used the same address in the example that came with node for this sample.)

And the final line writes a quick message to the console—this information doesn't get written to the web browser, but rather the console in which this program is running.

To run the program, you go to the directory where you saved it, and type (assuming the code is saved in the file called example.js, and that node is available in the path):

node example.js

Here's the full session running in the Linux command prompt window:

This is the web server itself running. Let's try it out. I opened up a web browser and put in the following URL: http://127.0.0.1:8124/hello/there/everyone

Here's what I saw in my browser:

Notice that I put in the same address and port as specified in the code. When I right-click in the browser and click View Source, here's what I see:

Greetings
/hello/there/everyone

Edited by WASDted: n/a

Votes + Comments
Well written and interesting
Good post :)
Well written and informative article
Nice tool indeed, I agree with your rating.
Pretty interesting :)
Attachments browser1.png 28.13 KB DW_9_120px.png 16.68 KB nodejs1.jpg 13.92 KB webserver.png 16.04 KB
1
Contributor
0
Replies
6
Views
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.