收集各种语言运行http 静态文件服务指令。
但求安装简单,运行简单,不用配置。
Node.js
http-server
$ npm install -g http-server
$ http-server -p 8000
node-static
$ npm install -g node-static
$ static -p 8000
live-server
$ npm install -g live-server
$ live-server --port=8000
light-server
$ npm install light-server
$ light-server -s . -p 8000
harp
$ sudo npm install -g harp
$ harp server --port 8000
Golang
ran
$ go get -u github.com/m3ng9i/ran
$ ran -p=8000 -l=true
spark
$ go get github.com/rif/spark
$ spark -port 8000 .
serve
$ go get github.com/kidoman/serve
或者使用 brew 安装(仅限macos)
$ brew install kidoman/tools/serve
使用
serve -p 8000 .
caddy
安装:
- brew (仅限macos)
$ brew install caddy
- 下载二进制运行文件
前往 https://github.com/caddyserver/caddy/releases 下载相应平台的文件,然后解压/安装运行。具体参照文档
使用
caddy file-server -listen :8000 -root . -browse
Python 2.x
$ python -m SimpleHTTPServer 8000
livereload
https://github.com/lepture/python-livereload
$ pip install livereload $ livereload -p 8000
Twisted
安装
$ pip install Twisted
使用
twisted -n web -p 8000 --path .
或者
$ python -c 'from twisted.web.server import Site; from twisted.web.static import File; from twisted.internet import reactor; reactor.listenTCP(8000, Site(File("."))); reactor.run()'
Python 3.x
$ python -m http.server 8000
Ruby
$ ruby -rwebrick -e'WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => Dir.pwd).start'
Ruby 1.9.2+
$ ruby -run -ehttpd . -p8000
adsf
$ gem install adsf
$ adsf -p 8000
Sinatra
$ gem install sinatra
$ ruby -rsinatra -e'set :public_folder, "."; set :port, 8000'
knod
$ gem install knod
$ knod -p 8000
serve
$ gem install serve
$ serve
httpit
$ gem install httpit
$ httpit
Perl
$ cpan HTTP::Server::Brick
$ perl -MHTTP::Server::Brick -e '$s=HTTP::Server::Brick->new(port=>8000); $s->mount("/"=>{path=>"."}); $s->start'
Plack
$ cpan Plack
$ plackup -MPlack::App::Directory -e 'Plack::App::Directory->new(root=>".");' -p 8000
Mojolicious
$ cpan Mojolicious::Lite
$ perl -MMojolicious::Lite -MCwd -e 'app->static->paths->[0]=getcwd; app->start' daemon -l http://*:8000
PHP (>= 5.4)
$ php -S 127.0.0.1:8000
Erlang
$ erl -s inets -eval 'inets:start(httpd,[{server_name,"NAME"},{document_root, "."},{server_root, "."},{port, 8000},{mime_types,[{"html","text/html"},{"htm","text/html"},{"js","text/javascript"},{"css","text/css"},{"gif","image/gif"},{"jpg","image/jpeg"},{"jpeg","image/jpeg"},{"png","image/png"}]}]).'
busybox httpd
$ busybox httpd -f -p 8000
webfs
$ webfsd -F -p 8000
官网:https://linux.bytesex.org/misc/webfs.html
IISExpress (Windows only)
C:\> "C:\Program Files (x86)\IIS Express\iisexpress.exe" /path:C:\MyWeb /port:8000
Drupal 5+
$ drush rs 8000
参考