Use Http-server to open a local server

Source: Internet
Author: User

Objective

In the writing front page, often in the browser run HTML page, directly open from the local folder is generally a file protocol, when the code exists http or https the link, the HTML page will not open normally, in order to resolve this situation, you need to open a local server locally.
This article is node.js in the use of http-server , open Local services, the steps are as follows:

1 Downloads node.js

Website address: https://nodejs.org
After the download is complete, enter the command at the command line $ node -v and $ npm -v check the version to verify that the installation was successful.

2 Downloads http-server

In Terminal input:
$ npm install http-server -g

3 Open http-serverService

The terminal enters the destination folder and then enters the terminal:

$ http-serverStarting up http-server, serving ./Available on:  http://127.0.0.1:8080  http://192.168.8.196:8080Hit CTRL-C to stop the server
4 Close http-serverService

Press the shortcut keyCTRL-C
The terminal shows ^Chttp-server stopped. that the service was turned off successfully.

Use Http-server to open a local server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.