Run a web server from any folder
A common need you can have is to spin up a Web Server from a particular folder in your system.
You have absolutely no time to configure a proper web server like Apache or Nginx because this is just for a few minutes or for testing your app.
How do you do so?
Depending on the language you prefer, you might already have all you need.
If you use Node.js and you have installed npm already, run
npm install -g http-server
and then run http-server in the folder you want to expose through your server.
By default it will start the server on port 8080, but you can change it using the -p flag (see more options by running http-server --help).
If you use Python and have it installed, just run
python -m SimpleHTTPServer 8080
(Python 2)
or
python -m http.server 8080
(Python 3)
to start a local server on port 8080.
If you use PHP and you run a modern version of it, run
php -S localhost:8080 download all my books for free
- javascript handbook
- typescript handbook
- css handbook
- node.js handbook
- astro handbook
- html handbook
- next.js pages router handbook
- alpine.js handbook
- htmx handbook
- react handbook
- sql handbook
- git cheat sheet
- laravel handbook
- express handbook
- swift handbook
- go handbook
- php handbook
- python handbook
- cli handbook
- c handbook
subscribe to my newsletter to get them
Terms: by subscribing to the newsletter you agree the following terms and conditions and privacy policy. The aim of the newsletter is to keep you up to date about new tutorials, new book releases or courses organized by Flavio. If you wish to unsubscribe from the newsletter, you can click the unsubscribe link that's present at the bottom of each email, anytime. I will not communicate/spread/publish or otherwise give away your address. Your email address is the only personal information collected, and it's only collected for the primary purpose of keeping you informed through the newsletter. It's stored in a secure server based in the EU. You can contact Flavio by emailing [email protected]. These terms and conditions are governed by the laws in force in Italy and you unconditionally submit to the jurisdiction of the courts of Italy.