← Go Back

How to Run a Basic HTTP Server

Python includes a basic HTTP server in its standard library that can be run from the terminal using:

python -m http.server

(On Windows, use py instead of python.)

This starts an HTTP server that listens for connections in every address and on port 8000, so we can interact with it at http://localhost:8000/. By default, the it serves files in the current working directory.

An alternate port can be specified using:

python -m http.server 8080

And to listen also in another address:

python -m http.server --bind 8080

http tcp cgi

🐍 You might also find interesting: