Skip to main content

node.js

AN EXAMPLE: WEBSERVER

This simple web server written in Node responds with "Hello World" for every request.
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
To run the server, put the code into a file example.js and execute it with the node program from the command line:
% node example.js
Server running at http://127.0.0.1:1337/
Here is an example of a simple TCP server which listens on port 1337 and echoes whatever you send it:
var net = require('net');

var server = net.createServer(function (socket) {
  socket.write('Echo server\r\n');
  socket.pipe(socket);
});

server.listen(1337, '127.0.0.1');

Comments

  1. Sữa ong chúa là gì, sữa ong chúa royal jelly 1000mg giúp cải thiện bổi bổ sức khỏe.Thuốc hỗ trợ điều trị ung thư sẽ giúp bạn điều trị căn bệnh ung thư hiệu quả hơn. Bạn đang bị rụng tóc, thuốc mọc tóc natrol biotin giúp bạn có mái tóc mượt mà và bóng mượt hơn. Nứt gót chân có nguy hiểm không? kem trị nứt gót chân của chúng tôi sẽ giúp bạn trị bệnh nứt gót hiệu quả, bệnh nấm móng có nguy hiểm hay không, có loại thuốc nào tốt giúp trị bệnh này không. Collagen là gì? collagen có tác dụng gì đối với cơ thể con người. Nám da có hại gì đối với cơ thể, hiện nay có loại kem trị nám tốt nhất hiện nay không

    ReplyDelete

Post a Comment

Pascal Fares and Open Source Lebanese Movement >

Popular posts from this blog

Setting up MySQL SSL and secure connections

There are different articles on how to setup MySQL with SSL but it’s sometimes difficult to end up with a good simple one. Usually, setting up MySQL SSL is not really a smooth process due to such factors like “it’s not your day”, something is broken apparently or the documentation lies... Read this article : Setting up MySQL SSL and secure connections Pre-requisite : Creating SSL Certificates and Keys Using openssl

New Language Expands on Google's Go

InfoWorld (09/23/16) Serdar Yegulalp   Polish developer Marcin Wrochniak has introduced Have, a computer language that transpiles to and expands on Google's Go. Wrochniak developed Have as a hobby project, with the goal of the language becoming a "companion" to Go that addresses some of its common "landmines." One of the most obvious differences between Have and Go is the formatting; Go uses curly braces similar to C/C++, while Have uses block indents like Python. Other differences address idiosyncrasies in Go. For example, the way that variable declaration, structs, and interfaces work have all been modified in Have to be more consistent with each other and to avoid internal inconsistencies that are a common source of bugs. The new language also plans to add generics to Go, which will enable programmers to create constructs in the language that use type parameters and make it possible to extend Have in ways not readily possible in Go. Have also features "...