http-server

npm 安裝本地server

插件地址:https://www.npmjs.com/package/http-server

// 安裝插件
npm install http-server -g

使用方式

http-server [path] [options]

// 在站點目錄下開啟命令行輸入
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 

參數

-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 打印以上列表并退出
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • Spring Cloud為開發人員提供了快速構建分布式系統中一些常見模式的工具(例如配置管理,服務發現,斷路器,智...
    卡卡羅2017閱讀 134,991評論 19 139
  • 1:簡介:命令行服務器。 2:優點:簡潔,輕便。3:安裝: 4:配置: 標紅的位置說明:5:參數說明:-p 端口號...
    麥殼兒UIandFE2閱讀 1,980評論 0 0
  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 173,556評論 25 708
  • 在開發中,有時候需要共享本地的靜態頁面給同事,以前一直用的phpstudy,也算比較方便。 但,僅僅是靜態頁面的話...
    姚冰coding閱讀 6,170評論 0 0
  • 故鄉長嶺 韓裕平 故鄉,故鄉,故土之鄉。故鄉,故鄉,故地之鄉。故鄉,故鄉,故人之鄉。 我的故鄉在長嶺,我愛我的故鄉...
    秭歸秀才9條命兒閱讀 455評論 4 4