Quickly build a local HTTP server

Source: Internet
Author: User

As we all know, the HTML file can be opened directly by the browser to see the effect of the visualization, but there are some limitations. For example, when we do mobile phone-side adaptation, can not directly see the effect of the phone side. In order not to be subject to such restrictions, it is strongly recommended to build a local HTTP server that maintains HTML pages and data files rather than loading them directly from the file system.

One install python simple HTTP server

Most LINUX/UNIX/MAC OS operating systems are installed by default and run the following command directly, where "8008" is the specified port number, and if Python is not installed, it can be downloaded to https://www.python.org/getit/.

  > python –m SimpleHTTPServer 8008



http://localhost:8008/ 将展示效果:

Ii. Installing the node. JS HTTP Server

Before running the following command, you need to make sure that node is installed globally, and you can run command node-v at terminal to see if it is installed.

  > npm install http-server –g
  >http-server .
  
  

The command can start a node. JS driver http server, the default port number is 8080, or you can specify a port number with the-p parameter, such as Http-server. -P 8888, at which point the port number is specified as "8888".

If you are running this command in a Linux/unix/mac operating system, you need to run it in sudo mode or root, that is, sudo npm i http-server-g and then enter the password to install it.

Browser input http://10.10.11.80:8081 or http://127.0.0.1:8081, you can have the following effects:

  

  

Quickly build a local HTTP 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.