簡易服務器:在命令執行的所在路徑啓動一個http服務器,而後你能夠經過瀏覽器訪問該路徑下的全部文件。css
在局域網內傳文件,或者本身測試使用都是很是方便的。html
1. 基於python

1.1. 基於Python2
python -m SimpleHTTPServer port
node
1
2
3 |
> python -m SimpleHTTPServer 8099
Serving HTTP on 0.0.0.0 port 8099 ...
127.0.0.1 - - [24/Oct/2017 11:07:56] "GET / HTTP/1.1" 200 - |
1.2. 基於python3
python3 -m http.server port
python
1
2
3
4
5 |
> python3 -m http.server 8099
Serving HTTP on 0.0.0.0 port 8099 (http://0.0.0.0:8099/) ...
127.0.0.1 - - [24/Oct/2017 11:05:06] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [24/Oct/2017 11:05:06] code 404, message File not found
127.0.0.1 - - [24/Oct/2017 11:05:06] "GET /favicon.ico HTTP/1.1" 404 - |
2. 基於nodejs
首先你要安裝nodejs
webpack
1
2
3
4
5 |
// 安裝
npm install http-server -g
// 用法
http-server [path] [options] |
1
2
3
4
5 |
// 安裝
npm install -g serve
// 用法
serve [options] <path> |
1
2
3
4
5 |
// 安裝
npm install webpack-dev-server -g
// 用法
webpack-dev-server |
1
2
3
4
5
6 |
// 安裝
npm install -g anywhere
// 用法
anywhere
anywhere -p port |

// 安裝
npm -g install puer
// 使用
puer
- 提供一個當前或指定路徑的靜態服務器
- 全部瀏覽器的實時刷新:編輯css實時更新(update)頁面樣式,其它文件則重載(reload)頁面
- 提供簡單熟悉的mock請求的配置功能,而且配置也是自動更新。
- 可用做代理服務器,調試開發既有服務器的頁面,可與mock功能配合使用
- 集成了weinre,並提供二維碼地址,方便移動端的調試
- 能夠做爲connect中間件使用(前提是後端爲nodejs,不然請使用代理模式)
文章來源:https://wdd.js.org/one-command-create-static-file-server.htmlgit