Recently saw on Habré a dispute over the fact that we do not need any scripting languages, except javascript. The statement, of course, is controversial, but I was interested in the possibility of using javascript on the server.
Searches brought me
here . Of all the solutions presented there, for some reason I (it just got up and earned the first time) chose the Node library for google v8.
Installation is quite simple: first install v8. You can either download it
from here , or if you have ubuntu (I have 9.04, I don’t know what's up with other versions and distributions), then you can install libv8 from the repositories. Node itself take
here .
Everything is established, now we can play! (I killed half of the weekend for these games, but more on that later). An http server (just saying hello to everyone) on Node looks like this:
')
var utils = ("/utils.js");
var http = ("/http.js");
http.createServer(function (request, response) {
response.sendHeader(200, {"Content-Type": "text/plain"});
response.sendBody("Hello!\n");
response.finish();
}).listen(8000);
utils.puts("Server running at 127.0.0.1:8000/");
In addition, in Node there are many very useful functions and objects for working with files, processes, convenient connection of modules, etc. And on Node they have already managed to write several libraries, a list
here .
The only disappointment that awaited me is the almost complete lack of documentation on both v8 (specifically for the built-in objects, which is strange, maybe I didn’t look well, if you can find it, please share the link, please), and by Node (there it is, as it were, but outdated). Fortunately, the situation a little clearer tests and source.
Yes. I said here that I had killed half the day off with this kind of thing. So, the result of all this is a small
simplex web framework and a
test application . While there are routes there, the template engine and the controller system. It is very simple, so it’s fine for the first acquaintance with Node.
Actually, everything. Related Links: