npm 安裝本地server
// 安裝插件
npm install http-server -g
使用方式
http-server [path] [options]
// 在站點(diǎn)目錄下開啟命令行輸入
http-server
// package.json
"scripts": {
"start": "http-server -a 0.0.0.0 -p 8000",
}
// 訪問: http://localhost:8080 or http://127.0.0.1:8080
參數(shù)
-p 端口號 (默認(rèn) 8080)
-a IP 地址 (默認(rèn) 0.0.0.0)
-d 顯示目錄列表 (默認(rèn) 'True')
-i 顯示 autoIndex (默認(rèn) 'True')
-e or --ext 如果沒有提供默認(rèn)的文件擴(kuò)展名(默認(rèn) 'html')
-s or --silent 禁止日志信息輸出
--cors 啟用 CORS via the Access-Control-Allow-Origin header
-o 在開始服務(wù)后打開瀏覽器
-c 為 cache-control max-age header 設(shè)置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 打印以上列表并退出