mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 00:52:29 +00:00

* add backticks around names * add single quotes around event names * add parenthesis after function names * add internal links between different sections * add external links to MDN for some JavaScript references * sort the link definitions alphabetically PR-URL: https://github.com/nodejs/node/pull/4054 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
648 B
648 B
Synopsis
An example of a web server written with Node.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');
}).listen(8124);
console.log('Server running at http://127.0.0.1:8124/');
To run the server, put the code into a file called example.js
and execute
it with the node program
> node example.js
Server running at http://127.0.0.1:8124/
All of the examples in the documentation can be run similarly.