Running a Simple HTTP Server with Python
I think this is going to be the shortest blog post of all time because running a Python HTTP server is incredibly straightforward. Python's HTTP server module lets you create a basic web server using just a single command. This server can serve files from a directory over the network, making it an excellent tool for quick testing and file sharing without the complexity of setting up a full-fledged web server.
You can start the Python HTTP server with the command python -m http.server 8000
, which serves files from the current directory on port 8000. You can choose any port number by replacing 8000
with your preferred port. However, if you select a lower port number, such as 80, you might need administrator privileges to run the server.
In this example, I have two files in a directory - one is a text file with a list of domains and the second is a simple YAML file.
If I run the command python -m http.server 8000
, it starts a web server and I Continue reading