← Go Back
(On Windows, use
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:
And to listen also in another address:
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 127.0.0.1 8080
🐍 You might also find interesting: