Zaga: Hi, zaga, I’m Linshan, today we are going to learn “a command to quickly start a Web service”, two NPM package can achieve, the following one.

Sometimes when we write a simple HTML test code, we need to use a Web service, through the browser: Localhost: XXXX/index. The HTML demo access to their test, in the absence of the node, often need to build or Apache Tomcat services (such as using PHP build), here, next to share the easiest way, this is also the node brings us great convenience.

To install node, you can download the node installation package directly. Double-click to install it.

To get down to business, a single command starts a server in the project file root directory

Method one (Anywhere)

The installation

Anywhere installation is very simple, with Node, NPM installed

npm install -g anywhere
Copy the code

use

After the installation is complete, open the command line directly under the folder you want to start the service, and enter anywhere and press Enter to start the service.
Specify boot port:

anywhere 8888 
Copy the code

It starts on port 8888


Method 2 (HTTP-Serve)

The installation

npm install http-server -g
Copy the code

use

After the installation is complete, open the command line in the folder where you want to start the service and enter HTTP-server



Enter the IP address shown above in the browser to access the port.

Http-server-c-1 can also be enabled, indicating that it is enabled when caching is disabled