First introduce http-server:
Http-server is a simple 0 configuration command line HTTP server, he is strong enough for production use, he is simple and can be truncated enough for testing, easy to use, and can be used for local development
1, first you want to install node
2. Can then be installed globally via NPM
sudo cnpm install http-server-g
I've also written about CNPM usage in the previous blogs, so I used cnpm here, and it's very quick to install.
After successful installation
3. Start using
Use the CD to jump to the folder you want
I used the test folder
Cd/path/test
Then use Http-server to start putting test on the local server.
Test george$ Http-server
The following interface will appear after success
Starting up Http-server, serving./available in: http://127.0.0.1:8081 http://10.1.1.232:8081Hit ctrl-c to Stop the server
4.options: Optional parameter options
-P: Port Used (default is 8080)
Okay, now, test the terminal.
: Test george$ http-server-p 8081Starting up Http-server, serving./available on: http://127.0.0.1:8081/ http 10.1.1.232:8081hit ctrl-c to stop the server
Then you can open this file on port 8081.
-a
The address to use (default is 0.0.0.0)
I'm not sure if this is the case, we have a clear idea.
-d
Show directory list (default = "True")
When you set this to False,
The terminal will display the following interface
Test george$ http-server-d falsestarting up Http-server, serving./available on: http://127.0.0.1:8080 http ://10.1.1.232:8080hit ctrl-c to stop the Server[fri may 17:32:57 gmt+0800 (CST)] "GET/" "mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) applewebkit/537.36 (khtml, like Gecko) chrome/58.0.3029.110 safari/537.36 "[Fri May 26 2017 17:32:5 7 gmt+0800 (CST)] "GET/" Error (404): "Not Found"
You enter http://127.0.0.1:8080/in the browser
You will find that the browser has been denied access request, unauthorized
-i
Show AutoIndex (default = "True")
-g
or --gzip
enabled (the default is "False"), it will be used in ./public/some-file.js.gz
place ./public/some-file.js
of the gzip compressed version of the file, and the request accepts gzip encoding.
-e
or --ext
Default file name extension (if not provided) (default is ' HTML ')
-s
or --silent
Suppress the log message from the output : This means that after you enter, the log message is not displayed
-o
Open the browser window when you start the server : that would be fine. Shuru Http-server-o in the folder and then automatically jumps to the browser.
-S
or --ssl
enable https: I personally think this is very good ah but I do not know why I will be error, you know that will be heard
-C
or --cert
the path to the SSL certificate file (default: CERT.PEM).
-K
or --key
path to the SSL key file (default: KEY.PEM).
-r
or --robots
provide a/robots.txt (the content defaults to ' user-agent:* \ ndisallow:/')
-h
or --help
Print this list and exit.
-c
sets the cache control Max-age header's cache time (in seconds), for example-C10 10 seconds (default is ' 3600 '). To disable caching, use-c-1.
-U
or --utc
use UTC time format in log messages
-c
sets the cache control Max-age header's cache time (in seconds), for example-C10 10 seconds (default is ' 3600 '). To disable caching, use-c-1.
-U
or --utc
use UTC time format in log messages
Http-server: An HTTP server with a simple 0 configuration command line