Use http-server (nodeJs) of a simple service

1. First, build an empty folder

2. Directly in the directory, global http-server installation 

3. Place your front-end packaged project folder in the new folder.

4. Enter hs then ./pub

5. At this time the service starts, the project can be accessed in the same local area network. http://172.16.17.225:8080/index.html Note: http-server does not define the path to the default folder is public.

It is said that default index.html file in our execution file directory, but did not test successful bloggers (direct port manually after /index.html).

6.  The following are some of the Order github

 

-pOr --portport to use (default is 8080)

-a Address to use (the default is 0.0.0.0)

-dDirectory listing (default true)

-iDisplay autoIndex (default true)

-gOr --gzipis enabled (default falsetime), it will be ./public/some-file.js.gzreplaced ./public/some-file.jswhen the compressed version of the file exists and gzip request acceptance gzip encoding. If brotli also enabled, it will try first service brotli.

-bOr --brotliis enabled (default falsetime), it will be ./public/some-file.js.brreplaced ./public/some-file.jswhen the file exists and compressed version of the request accepting brotli brcoding. If gzip is also enabled, it will first attempt to provide brotli.

-eOr --extif no default file extension (by default html)

-sOr --silentsuppressed from the output log message

--cors通过Access-Control-Allow-Origin标头启用CORS

-o [path]启动服务器后打开浏览器窗口。(可选)提供要打开的URL路径。例如:-o / other / dir /

-c设置缓存控制max-age标头的缓存时间(以秒为单位),例如-c1010秒(默认为3600)。要禁用缓存,请使用-c-1

-U--utc在日志消息中使用UTC时间格式。

--log-ip启用客户端IP地址的记录(默认值:) false

-P或者将--proxy所有无法在本地解析的请求代理到给定的URL。例如:-P http://someurl.com

--username 基本身份验证的用户名[无]

--password 基本身份验证密码[无]

-S--ssl启用https。

-C--certssl cert文件的路径(默认值:) cert.pem

-K--keyssl密钥文件的路径(默认值:) key.pem

-r--robots提供/robots.txt(其内容默认为User-agent: *\nDisallow: /

-h--help打印此列表并退出。

 

 

 

 

 

-p 端口号 (默认 8080)
-a IP 地址 (默认 0.0.0.0)
-d 显示目录列表 (默认 'True')
-i 显示 autoIndex (默认 'True')
-e or --ext 如果没有提供默认的文件扩展名(默认 'html')
-s or --silent 禁止日志信息输出
--cors 启用 CORS via the Access-Control-Allow-Origin header
-o 在开始服务后打开浏览器-c 为 cache-control max-age header 设置Cache time(秒) , e.g. -c10 for 10 seconds (defaults to '3600'). 禁用 caching, 则使用 -c-1.-U 或 --utc 使用UTC time 格式化log消息
-P or --proxy Proxies all requests which can't be resolved locally to the given url. e.g.: -P http://someurl.com
-S or --ssl 启用 https
-C or --cert ssl cert 文件路径 (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 打印以上列表并退出

Guess you like

Origin www.cnblogs.com/mrbabibo/p/11206563.html