In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you how "Node.js realizes hello world", the content is simple and easy to understand, and the organization is clear. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn this article "Node.js realizes hello world".
First download node.js, then extract it to disk E, rename it node, and then start the menu by typing cmd, and use cd command to switch to the decompression directory of nodejs:
*** Example: Hello world.
Create a hello.js file in the node directory and type:
var sys = require("sys"); sys.puts("Hello world");
Then we type the command node hello.js into the naming platform and see the naming platform output Hello world.
The second example is Hello World2.
Okay, this time we'll try outputting hello world from the browser. Create http.js in the node directory and type:
var sys = require("sys"), http = require("http"); http.createServer(function(request, response) { response.sendHeader(200, {"Content-Type": "text/html"}); response.write("Hello World! "); response.close(); }).listen(8080); sys.puts("Server running at http://localhost:8080/");
Then we type node http.js in the naming console and http://localhost:8080/in the browser
The third example is Hello World2.
Node.js provides a Buffer class for converting strings with different encodings. There are currently three types supported: 'ascii','utf8'and' binary'. See details here.
var Buffer = require('buffer').Buffer, buf = new Buffer(256), len = buf.write('\u00bd + \u00bc = \u00be', 0); console.log(len + " bytes: " + buf.toString('utf8', 0, len));
The fourth example is Hello World3.
//synopsis.js 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/'); above is all the content of "Node.js how to implement hello world", thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.