HTTP Server in One Line of Python Code

Open a command prompt or terminal window and navigate to the directory where you want to launch the HTTP server.

python3 -m http.server

Python starts an HTTP server on port 8000 and binds it to all the available network interfaces on your machine, which are denoted with a special IP address.

To explicitly set the port number, e.g. 8080, that your HTTP server should be listening on, append it as a parameter:

python3 -m http.server 8080