Run Webserver with current folder as root

Different ways to run a webserver using the current directory as root. Useful to serve static files.

If you use NPM, install serve using npm install serve -g. Then run it using the command…

serve

If you have PHP install, use the command…

php -Slocalhost:8000

If python is your thing, use command…

python -m SimpleHTTPServer 8000

If you want to use Python3, use…

python3 -m http.server

You can exit for any of these using the keyboard shortuct Ctrl+C.

Source

Author: Binny V A
A philosopher programmer who specializes in backend development and stoicism.

Leave a Reply

Your email address will not be published. Required fields are marked *