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
-p
Or --port
port to use (default is 8080)
-a
Address to use (the default is 0.0.0.0)
-d
Directory listing (default true
)
-i
Display autoIndex (default true
)
-g
Or --gzip
is enabled (default false
time), it will be ./public/some-file.js.gz
replaced ./public/some-file.js
when the compressed version of the file exists and gzip request acceptance gzip encoding. If brotli also enabled, it will try first service brotli.
-b
Or --brotli
is enabled (default false
time), it will be ./public/some-file.js.br
replaced ./public/some-file.js
when the file exists and compressed version of the request accepting brotli br
coding. If gzip is also enabled, it will first attempt to provide brotli.
-e
Or --ext
if no default file extension (by default html
)
-s
Or --silent
suppressed from the output log message
--cors
通过Access-Control-Allow-Origin
标头启用CORS
-o [path]
启动服务器后打开浏览器窗口。(可选)提供要打开的URL路径。例如:-o / other / dir /
-c
设置缓存控制max-age标头的缓存时间(以秒为单位),例如-c10
10秒(默认为3600
)。要禁用缓存,请使用-c-1
。
-U
或--utc
在日志消息中使用UTC时间格式。
--log-ip
启用客户端IP地址的记录(默认值:) false
。
-P
或者将--proxy
所有无法在本地解析的请求代理到给定的URL。例如:-P http://someurl.com
--username
基本身份验证的用户名[无]
--password
基本身份验证密码[无]
-S
或--ssl
启用https。
-C
或--cert
ssl cert文件的路径(默认值:) cert.pem
。
-K
或--key
ssl密钥文件的路径(默认值:) 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 打印以上列表并退出