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 -rwebrick -e"WEBrick::HTTPServer.new(:DocumentRoot => '.', :Port => 0).start"
python -m SimpleHTTPServer
python3 -m http.server
twistd -n web --path . --port 8000
Not built-in so install doing
npm install http-server -g
and launch
http-server
php -S localhost:8080
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 !!