This article is a mirror article of machine translation, please click here to jump to the original article.

View: 9389|Reply: 3

window, install http-server in nodejs and turn on the HTTP server

[Copy link]
Posted on 1/23/2019 1:14:19 PM | | | |
http-server is a simple, zero-configuration command-line HTTP server, based on nodeJs.

If you don't want to write nodeJs web-server.js repeatedly, you can use this.

Install (global install plus -g):


Windows Use:

Enable command line input in the site directory




Show the image above, enter in your browserhttp://127.0.0.1:8080, that is, you can display the web files index.html in your file directory.

Success



Parameter configuration:

-p port number (default 8080)

-a IP address (default 0.0.0.0)

-d Show directory list (default 'true')

-i shows autoIndex (default 'True')

-e or --ext if the default file extension (default 'html') is not provided

-s or --silent prohibits log information output

--cors enables CORS via the Access-Control-Allow-Origin header

-o Open the browser after starting the service
-c Set Cache time(seconds) for cache-control max-age header , e.g. -c10 for 10 seconds (defaults to '3600'). If caching is disabled, use -c-1.
-U or --utc to format log messages using UTC time

-P or --proxy Proxies all requests which can't be resolved locally to the given url. e.g.: -Phttp://someurl.com

-S or --ssl to enable https

-C or --cert ssl cert file path (default: cert.pem)

-K or --key Path to ssl key file (default: key.pem).

-r or --robots Provide a /robots.txt (whose content defaults to 'User-agent: *\nDisallow: /')

-h or --help print the above list and exit
Resources:https://www.npmjs.com/package/http-server





Previous:Recruitment: One Huawei Personnel Director
Next:Publish executes the dotnet xx.dll of the application
Posted on 3/8/2019 2:35:24 PM |
Thanks for sharing
 Landlord| Posted on 3/15/2022 11:35:08 AM |
View the path to the npm global installation module

 Landlord| Posted on 11/26/2024 7:34:14 PM |
live-server Another http service:



Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com