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.
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)
$ lein simpleton 8000
$ crystal eval 'require "http/server"; HTTP::Server.new(8000, HTTP::StaticFileHandler.new(".")).listen'
$ elixir --no-halt --app inets -e ":inets.start(:httpd,[{:server_name,'s'},{:document_root,'.'},{:server_root,'.'},{:port,8000}])"
$ 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 get -u github.com/xyproto/algernon
$ algernon -x 8000
caddy -port 8000
$ go get github.com/vwochnik/gost
$ gost -port 8888 .
$ go get -u github.com/m3ng9i/ran
$ ran -p 8000
$ go get github.com/rif/spark
$ spark -port 8000 .
$ cabal install maid
$ maid 8000
$ cabal install wai-app-static
$ warp -p 8000
$ ros install clack
$ clackup <(echo "(lack:builder (:static :path #'identity) #'identity)")
$ node -e "require('http').createServer((req,res)=>{require('fs').readFile(req.url.substr(1),(err,e)=>{res.write(e);res.end()})}).listen(8088)"
$ npm install anywhere -g
$ anywhere -p 8000
$ npm install -g glance
$ glance -p 8000
$ npm install -g harp
$ harp server --port 8000
$ npm install -g http-server
$ http-server -p 8000
$ npm install -g node-static
$ static -p 8000
$ npm install -g superstatic
$ superstatic public --port 8000
$ cpan HTTP::Server::Brick
$ perl -MHTTP::Server::Brick -e '$s=HTTP::Server::Brick->new(port=>8000); $s->mount("/"=>{path=>"."}); $s->start'
$ cpan Plack
$ plackup -MPlack::App::Directory -e 'Plack::App::Directory->new(root=>".");' -p 8000
$ cpan Mojolicious::Lite
$ perl -MMojolicious::Lite -MCwd -e 'app->static->paths->[0]=getcwd; app->start' daemon -l http://*:8000
$ php -S 127.0.0.1:8000
$ drush rs 8000
$ php artisan serve --host=127.0.0.1 --port=8000
$ python -m SimpleHTTPServer 8000
$ python -m http.server 8000
$ pip install twisted
$ twistd -n web -p 8000 --path .
$ Rscript -e 'servr::httd()' -p8000
$ ruby -run -ehttpd . -p8000
$ gem install adsf
$ adsf -p 8000
$ gem install knod
$ knod -p 8000
$ gem install rack
$ rackup -b 'use Rack::Static, :index => 'index.html'; run Rack::File.new('.')"
$ gem install serve
$ serve 8000
$ gem install sinatra
$ ruby -rsinatra -e'set :public_folder, "."; set :port, 8000'
$ cargo install https
$ http -p 8000
$ cargo install miniserve
$ miniserve -p 8000 .
$ cargo install simple-http-server
$ simple-http-server -p 8000 -- .
$ busybox httpd -f -p 8000
$ ngrok http 8000
$ webfsd -F -p 8000
C:\> "C:\Program Files (x86)\IIS Express\iisexpress.exe" /path:C:\MyWeb /port:8000