使用http -server 搭建本地簡易文件服務器

安裝

npm install http-server -ghtml

使用

1. cd project .

2. hs [pwd] -o, 默認是當前路徑 ./

3. 其餘選項

-p Port to use (defaults to 8080) (經常使用)npm

-a Address to use (defaults to 0.0.0.0) (更換主機,基本不用)跨域

-d Show directory listings (defaults to 'True') (展現目錄,基本不用)瀏覽器

-i Display autoIndex (defaults to 'True') (默認打開index.html)緩存

-g or --gzip When enabled (defaults to 'False') it will serve ./public/some-file.js.gz in place of ./public/some-file.js when a gzipped version of the file exists and the request accepts gzip encoding. (壓縮文件優先, 基本不用)cors

-e or --ext Default file extension if none supplied (defaults to 'html') (默認文件後綴)日誌

-s or --silent Suppress log messages from output (控制檯打印日誌)orm

--cors Enable CORS via the Access-Control-Allow-Origin header (支持跨域,基本不用)server

-o Open browser window after starting the server (打開瀏覽器)htm

-c Set cache time (in seconds) for cache-control max-age header, e.g. -c10 for 10 seconds (defaults to '3600'). To disable caching, use -c-1.(緩存時間)

-U or --utc Use UTC time format in log messages. (打印時間的格式)

-S or --ssl Enable https. (打開https)

經常使用

hs ./afaf -p 9999 -o

-o 要放在最後

相關文章
相關標籤/搜索