io.js v2.2.0 Documentation

Table of Contents


An example of a web server written with io.js which responds with 'Hello World':

var http = require('http');

http.createServer(function (request, response) {
  response.writeHead(200, {'Content-Type': 'text/plain'});
  response.end('Hello World\n');

console.log('Server running at');

To run the server, put the code into a file called example.js and execute it with the iojs program

> iojs example.js
Server running at

All of the examples in the documentation can be run similarly.