$ apt-get install openssl libssl-dev
Create a file named test.js, and copy and paste the code below
To start the server go to the terminal and the run the script you created by typing
//how to run the server output hello world
var http = require('http');
var server = http.createServer(function(request, response){
response.writeHead(200, {
'Content-type' : 'text/plain'
});
response.end('hello world');
});
// where the host in located
server.listen(8000); //see the code below
console.log('listening on http://127.0.0.1:8000'); //echo in the terminal whatever you want
$ node test.js
Now go to the browser and enter http://127.0.0.1:8000 and your done.
Resource: http://net.tutsplus.com/tutorials/javascript-ajax/this-time-youll-learn-node-js/
No comments:
Post a Comment