HTTP static servers

October 31, 2020    Article    99 words    1 min read

The commands below will start a HTTP server on port 8080 and serve the files in the current directory (you will be able to acces it at http://localhost:8080). If there are two commands, the first one will install a dependency.

Node.js

$ npm install -g node-static
$ static -p 8080

Ruby

$ ruby -rwebrick -e'WEBrick::HTTPServer.new(:Port => 8080, :DocumentRoot => Dir.pwd).start'

Ruby 1.9.2+

$ ruby -run -ehttpd . -p8080

Perl

$ cpan HTTP::Server::Brick
$ perl -MHTTP::Server::Brick -e '$s=HTTP::Server::Brick->new(port=>8080); $s->mount("/"=>{path=>"."}); $s->start'

PHP 5.4+

$ php -S 127.0.0.1:8080

Python 2

$ python -m SimpleHTTPServer 8080

Python 3

$ python -m http.server 8080