How to — Start a local server
by Laurel on 9.23.2021


Sometimes it’s annoying to always have to drag and drop your website’s index.html into your browser to test…

And sometimes it’s annoying your computer doesn’t automatically direct to the index.html when you’re inside a folder…

And sometimes you need to use bookmarklets on your page that only work when your site is online, but you’re not ready to put it online…

And sometimes you easily want to test your website on mobile without having to upload it to the world wide web…

So, sometimes you want to… start a local server 🤠🌾


To start a local server with Python, you just need to:

Step 1. Navigate to your class’s folder in Terminal


Open up Terminal program on your Mac.

I like to type cd  (which means “change directory”) and then drag my folder from Finder into Terminal. So I personally see something like this:

cd /Users/laurelschwulst/Sites/metadata.fan

Press enter to get to that place.

Step 2. Fire up your local server


Once you’re at the right spot, type this into Terminal:

python -m SimpleHTTPServer

Note this above command works if you have Python 2 installed. If that doesn’t work, you might have Python 3 installed instead. In that case, try python3 -m http.server instead of the above command. You can learn more here. I found this page by Googling “python local server.”

Then press enter.

Terminal will tell you something like…
Serving HTTP on 0.0.0.0 port 8000 ...

Which means you can type localhost:8000 into your web browser and see:


The below is optional. But cool…


The cool thing about local servers is that they’re local. Anyone on the same wifi address can technically access them. Including your mobile device, if you want to test your site this way.