Home  >  Article  >  Web Front-end  >  How to build a simple static file http server

How to build a simple static file http server

一个新手
一个新手Original
2017-10-26 10:25:163740browse

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.

1 Based on python

How to build a simple static file http server

1.1 Based on Python2

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 -

1.2 Based on python3

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 -

2 Based on nodejs

First you need to install nodejs
How to build a simple static file http server

2.1 http-server

// 安装
npm install http-server -g

// 用法
http-server [path] [options]

2.2 serve

// 安装
npm install -g serve

// 用法
serve [options] <path>

2.3 webpack-dev-server

// 安装
npm install webpack-dev-server -g

// 用法
webpack-dev-server

2.4 anywhere

// 安装
npm install -g anywhere

// 用法
anywhere
anywhere -p port

2.5 puer

How to build a simple static file http server

// 安装
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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn