Multi-languages one liner web servers!

24 May 2013

You have a lot of uses cases where you need to have a web server, like when you use ajax calls. We will review some way to do it with different programming languages.

Ruby

ruby -rwebrick -e"WEBrick::HTTPServer.new(:DocumentRoot => '.', :Port => 0).start"

Python

Version 2

python -m SimpleHTTPServer

Version 3

python3 -m http.server

Twisted python library way in Python

twistd -n web --path . --port 8000

Node

Not built-in so install doing

npm install http-server -g

and launch

http-server

PHP (>= 5.4)

php -S localhost:8080

Perl

Not built-in so install doing

perl -MCPAN -e 'install HTTP::Server::Brick'

and launch

perl -MHTTP::Server::Brick -e '$s=HTTP::Server::Brick->new(port=>8081); $s->mount("/"=>{path=>"/home/thomas/code"}); $s->start'

Feel free to submit others examples with a Github push request going to this post in my blog repository I will add credits if you do so !!

web server tools