Home > Article > Web Front-end > How to build a simple static file http server
Simple server: Start an http server in the path where the command is executed, and then you can access all files in the path through the browser.
It is very convenient to transfer files within the LAN or test and use it yourself.
python -m SimpleHTTPServer port
> 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 -
python3 -m http.server port
> 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 -
First you need to install nodejs
// 安装 npm install http-server -g // 用法 http-server [path] [options]
// 安装 npm install -g serve // 用法 serve [options] <path>
// 安装 npm install webpack-dev-server -g // 用法 webpack-dev-server
// 安装 npm install -g anywhere // 用法 anywhere anywhere -p port
// 安装 npm -g install puer // 使用 puer - 提供一个当前或指定路径的静态服务器 - 所有浏览器的实时刷新:编辑css实时更新(update)页面样式,其它文件则重载(reload)页面 - 提供简单熟悉的mock请求的配置功能,并且配置也是自动更新。 - 可用作代理服务器,调试开发既有服务器的页面,可与mock功能配合使用 - 集成了weinre,并提供二维码地址,方便移动端的调试 - 可以作为connect中间件使用(前提是后端为nodejs,否则请使用代理模式)
The above is the detailed content of How to build a simple static file http server. For more information, please follow other related articles on the PHP Chinese website!