Tip: Run a simple server with Python
By Juan Manuel Allo Ron on May 21, 2020
I used this all the time! When you want to quickly serve a website or a page, or even mock a quick API, you can use python to start a server:
python -m SimpleHTTPServer
This will automatically start a server on port 3000
serving files in the current directory. If you want to change the port, just append the port number at the end: python -m SimpleHTTPServer 4000
Using Python3:
python3 -m http.server
NOTE: python3 will start in 8000
as the default port.
Even better you can add an alias to your terminal, I use the following:
alias pserver="python3 -m http.server"
You can still adde the port like this: pserver 4000
.
Enjoy!!
Catch up with me on X (twitter):@juan_allo
Share
---
Similar Articles

Tip: use Z
May 28, 2020
Aren’t you tired of always typing the same routes in the terminal? When I found z it changed my productivity. What’s z? A terminal command to help you quickly navigate across directories…

Tip: Watch out for null in default params
Jun 4, 2020
Defaults in function parameters is a feature that simplified my code a lot. But there is one caveat that we need to be aware of! Let’s start with an example:

Tip: Syntax Highlighting with BAT
May 7, 2020
Terminal command cat is a standard tool to print file contents to the console. I use it all the time but recently I found bat and it changed my life!

Tip: list NPM scripts
May 14, 2020
In this quick-tip I will show you how to list scripts from the terminal