web-servers
This is a collection of one-liner server. The idea is from this gist. I create this repo because there are more solutions scattered in the comments. It would be better that we have a space to gather them. I appreciate all the contributors to the original discussion thread.
I use the original setting for all the examples. All of them will run the server at port 8000 in your current working directory.
Contents
Language
Meta
If you have any suggestions, drop them in a new pull request. To get on this list, a solution must:
- serve static files using your current directory (or a specified directory) as the server root,
- be able to be run with a single, one line command (dependencies are fine if they're a one-time thing),
- serve basic file types (html, css, js, images) with proper mime types,
- require no configuration (from files or otherwise) beyond the command itself (no framework-specific servers, etc)
- must run, or have a mode where it can run, in the foreground (i.e. no daemons)
Clogure
Leiningen
$ lein simpleton 8000Crystal
$ crystal eval 'require "http/server"; HTTP::Server.new(8000, HTTP::StaticFileHandler.new(".")).listen'Elixir
elixir --no-halt --app inets -e ":inets.start(:httpd,[{:server_name,'s'},{:document_root,'.'},{:server_root,'.'},{:port,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"}]}]).'Go
Algernon
$ go get -u github.com/xyproto/algernon
$ algernon -x 8000Candy
caddy -port 8000Gost
$ go get github.com/vwochnik/gost
$ gost -port 8888 .Ram
$ go get -u github.com/m3ng9i/ran
$ ran -p 8000Spark
$ go get github.com/rif/spark
$ spark -port 8000 .Haskell
maid
cabal install maid
maid 8000wai-app-static
cabal install wai-app-static
warp -p 8000Lisp
Clack
$ ros install clack
$ clackup <(echo "(lack:builder (:static :path #'identity) #'identity)")
Node.js
Anywhere
$ npm install anywhere -g
$ anywhere -p 8000glance
$ npm install -g glance
$ glance -p 8000Harp
$ npm install -g harp
$ harp server --port 8000http-server
$ npm install -g http-server # install dependency
$ http-server -p 8000node-static
$ npm install -g node-static
$ static -p 8000Superstatic
$ npm install -g superstatic
$ superstatic public --port 8000Perl
$ 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 8000Mojolicious
$ cpan Mojolicious::Lite
$ perl -MMojolicious::Lite -MCwd -e 'app->static->paths->[0]=getcwd; app->start' daemon -l http://*:8000PHP
$ php -S 127.0.0.1:8000Drush
$ drush rs 8000Laravel
$ php artisan serve --host=127.0.0.1 --port=8000Python
Python 2
$ python -m SimpleHTTPServer 8000Python 3
$ python -m http.server 8000Twisted
$ pip install twisted
$ twistd -n web -p 8000 --path .R
$ Rscript -e 'servr::httd()' -p8000Ruby
$ ruby -run -ehttpd . -p8000adsf
$ gem install adsf
$ adsf -p 8000Knod
$ gem install knod
$ knod -p 8000Rack
$ gem install rack
$ rackup -b 'use Rack::Static, :index => 'index.html'; run Rack::File.new('.')"Serve
$ gem install serve
$ serve 8000Sinatra
$ gem install sinatra
$ ruby -rsinatra -e'set :public_folder, "."; set :port, 8000'Rust
Host These Things Please
$ cargo install https
$ http -p 8000miniserve
$ cargo install miniserve
$ miniserve -p 8000 .simple-http-server
$ cargo install simple-http-server
$ simple-http-server -p 8000 -- .Other
busybox httpd
$ busybox httpd -f -p 8000ngrok
$ ngrok http 8000webfs
$ webfsd -F -p 8000IIS Express
C:\> "C:\Program Files (x86)\IIS Express\iisexpress.exe" /path:C:\MyWeb /port:8000