Programming Language: Python Difficulty: Beginner

Sometimes you just need a quick way to serve files locally—maybe you’re testing a website, sharing files across devices, or previewing a project. Python makes this ridiculously easy with a built-in command.

No installs, no setup, no extra tools.

What This Does

The http.server module in Python lets you turn any folder on your computer into a basic web server.

Once it’s running, you can open a browser and access your files like a website.

Requirements

  • Python installed (version 3.x)
  • A terminal or command prompt

You can check if Python is installed by running:

python --version

or

python3 --version

Step 1: Open Your Terminal

  • On Windows: open Command Prompt or PowerShell
  • On macOS/Linux: open Terminal

Step 2: Navigate to Your Folder

Use the cd command to move into the folder you want to serve.

Example:

cd Desktop/my-website

Whatever is inside this folder will be accessible from the browser.

Step 3: Start the Server

Run this command:

python -m http.server

or if your system uses python3:

python3 -m http.server

You should see something like:

Serving HTTP on 0.0.0.0 port 8000

Step 4: Open It in Your Browser

Go to:

http://localhost:8000

You’ll now see:

  • Your files listed
  • or your website (if there’s an index.html file)

Optional: Use a Different Port

By default, it uses port 8000. You can change it like this:

python -m http.server 3000

Then visit:

http://localhost:3000

Optional: Access from Another Device

If you’re on the same network, other devices can access your server using your computer’s local IP address.

Example:

http://192.168.56.67:8000

How to Stop the Server

Just press:

Ctrl + C

in your terminal.

When to Use This

  • Testing HTML/CSS/JS files
  • Quickly sharing files on your network
  • Previewing static websites
  • Learning and experimenting

Limitations

  • No security features
  • Not meant for production use
  • No advanced backend functionality