简易服务器:在命令执行的所在路径启动一个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