Skip to main content
LogoJuan Manuel Allo Ron

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

@2025 Juan Manuel Allo Ron. All Rights reserved