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