Http-server: An HTTP server with a simple 0 configuration command line

Source: Internet
Author: User
Tags install node ssl certificate

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.

-aThe address to use (default is 0.0.0.0)

I'm not sure if this is the case, we have a clear idea.

-dShow 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

-iShow AutoIndex (default = "True")

-gor --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.

-eor --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

-oOpen 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

-Cor --cert the path to the SSL certificate file (default: CERT.PEM).

-Kor --key path to the SSL key file (default: KEY.PEM).

-ror --robots provide a/robots.txt (the content defaults to ' user-agent:* \ ndisallow:/')

-hor --help Print this list and exit.

-csets 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.

-Uor --utc use UTC time format in log messages

-csets 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.

-Uor --utc use UTC time format in log messages

Http-server: An HTTP server with a simple 0 configuration command line

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.