Pages

Sunday, May 21, 2017

Bash: Running local web-server on your system

To run a local web-server at a directory, you can use either python, ruby, node.js or php.
You can choose your suitable way out of the below provided options.
Using python
To run the server, go to the directory & execute this command with Python 2
python -m SimpleHTTPServer 8000
or with Python 3
python -m http.server 8000
Using ruby
First, install the ruby gem named 'serve'
sudo gem install serve
To run the server, go to the directory & execute this command
serve 8000
Using node.js
First, install the app named 'http-server'
npm install http-server -g
To run the server, go to the directory & execute this command
http-server ./ -p 8000
You can use any other node based servers as well like puer
Using php
To run the server, go to the directory & execute this command
php -S 0.0.0.0:8000
Note: Press Ctrl-C to quit any of the above listed server

No comments:

Post a Comment