在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ 如何通過nodejs快速搭建本地局域網(wǎng)環(huán)境?

如何通過nodejs快速搭建本地局域網(wǎng)環(huán)境?

希望通過node.js快速搭建一個(gè)本地局域網(wǎng)環(huán)境,來讓同局域網(wǎng)的設(shè)備訪問下載文件以及訪問html文件。
有相關(guān)的npm包或技術(shù)推薦嗎?

回答
編輯回答
敢試

node-static

npm i -g node-static
static --help
USAGE: /Users/svpg/.config/yarn/global/node_modules/.bin/static [-p <port>] [<directory>]

simple, rfc 2616 compliant file streaming module for node

Options:
  --port, -p          TCP port at which the files will be served                                                          [default: 8080]
  --host-address, -a  the local network interface at which to listen                                                      [default: "127.0.0.1"]
  --cache, -c         "Cache-Control" header setting, defaults to 3600                                                  
  --version, -v       node-static version                                                                               
  --headers, -H       additional headers (in JSON format)                                                               
  --header-file, -f   JSON file of additional headers                                                                   
  --gzip, -z          enable compression (tries to serve file of same name plus '.gz')                                  
  --spa               serve the content as a single page app by redirecting all non-file requests to the index html file
  --indexFile, -i     specify a custom index file when serving up directories                                             [default: "index.html"]
  --help, -h          display this help message                                                                         

使用:

# 監(jiān)聽所有網(wǎng)卡的9999端口
static -p 9999 -a 0.0.0.0
2017年12月12日 06:27
編輯回答
臭榴蓮

anywhere了解一下

2017年5月14日 05:54
編輯回答
雨萌萌
npm i anywhere -g
//打開命令行,在你的項(xiàng)目或者桌面路徑下
anywhere 8080
//同一個(gè)局域網(wǎng)都可以訪問你電腦的ip:8080了
2018年8月12日 17:59
編輯回答
扯不斷
npm i http-server -g
// 想要host的目錄下
http-server 
2017年12月3日 01:29