Ensure Python is installed on your system. Verify it by running python --version or python3 --version in your terminal.
Open your terminal, navigate to the folder where you want to set up the server, and make it your working directory.
Run python -m http.server for Python 3 or python -m SimpleHTTPServer for Python 2 to initiate a basic HTTP server.
Add a port number to the command (e.g., python -m http.server 8000) to run the server on a specific port instead of the default (port 8000).
Open a browser and type http://localhost:8000 (or the specified port) to view the server’s content in your browser.
To stop the server, press Ctrl+C in the terminal. This will terminate the running process.